アットウィキロゴ

game0108

import java.awt.*;
import java.awt.event.*;

class game0108 extends Frame implements Runnable{

int mode;
int t;
int card1,card2,card3;

public static void main(String [] args) {
        Frame f=new game0108();
        f.setTitle("game0108");
        f.setSize(700,700);
        f.setBackground(Color.yellow);
        f.setVisible(true);
    }

game0108(){
t=0;

Thread th=new Thread(this);
th.start();
addWindowListener(new stopwin());
}


class stopwin extends WindowAdapter{
    public void windowClosing(WindowEvent we){System.exit(0);}
}  


public void run(){
double x;
t=1;  
mode=0;
while(t<30){

card1=1;
x=Math.random();
if (x>0.3)card1=2;
if (x>0.6)card1=3;

card2=1;
x=Math.random();
if (x>0.3)card2=2;
if (x>0.6)card2=3;

card3=1;
x=Math.random();
if (x>0.3)card3=2;
if (x>0.6)card3=3;

repaint();
try{
Thread.sleep(500);
}catch(InterruptedException e){}
t=t+1;  
}
mode=100;
repaint();
}


public void paint(Graphics g){

if (mode<50){
g.setColor(Color.yellow);
g.fillRect(0,0,700,700);
g.setColor(Color.black);
if (card1==1)g.drawString("A",100,300);
if (card1==2)g.drawString("B",100,300);
if (card1==3)g.drawString("C",100,300);  

if (card2==1)g.drawString("A",200,300);
if (card2==2)g.drawString("B",200,300);
if (card2==3)g.drawString("C",200,300);

if (card3==1)g.drawString("A",300,300);
if (card3==2)g.drawString("B",300,300);
if (card3==3)g.drawString("C",300,300);
}

if(mode>50){
g.setColor(Color.yellow);
g.fillRect(0,0,700,700);
g.setColor(Color.black);
g.drawString("駄目でした",100,300);
}



}
}
最終更新:2011年02月09日 04:15