📄 test.java
字号:
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class test extends Applet
implements ActionListener
{ public int x,y,x1,y1,choose;
public int index=0,fill=0; //index是状态
public Image[] img;
Label label1=new Label("STEP:1.心里任意想一个两位数字!将此数减去十位,各位的数字."); //定义控件对象
Label label2=new Label(" 2.得数在下面的图表中找到,观察旁边的图案5秒以上.");
Label label3=new Label(" 3.点击guess,看看有什么?");
Button bu1=new Button("Reset");
Button bu2=new Button("Guess");
result re=new result();
public void init()
{ img=new Image[10];
img[0]=getImage(getDocumentBase(),"pic/s0.GIF");
img[1]=getImage(getDocumentBase(),"pic/s1.GIF");
img[2]=getImage(getDocumentBase(),"pic/s2.GIF");
img[3]=getImage(getDocumentBase(),"pic/s3.GIF");
img[4]=getImage(getDocumentBase(),"pic/s4.GIF");
img[5]=getImage(getDocumentBase(),"pic/s5.GIF");
img[6]=getImage(getDocumentBase(),"pic/s6.GIF");
img[7]=getImage(getDocumentBase(),"pic/s7.GIF");
img[8]=getImage(getDocumentBase(),"pic/s8.GIF");
img[9]=getImage(getDocumentBase(),"pic/s9.GIF");
Panel pa1=new Panel();
Panel pa2=new Panel();
Panel pa3=new Panel();
Panel pa4=new Panel();
pa1.setLayout(new GridLayout(3,1));
pa1.add(label1);
pa1.add(label2);
pa1.add(label3);
// pa4.add(label1);
pa2.add(bu1);
pa2.add(bu2);
pa3.add(re);
re.setSize(80,60);
add("West",pa3);
add("Center",pa1);
add("East",pa2);
bu1.addActionListener(this);
bu2.addActionListener(this);
choose=(int)Math.floor(Math.random()*9); //算出0-9的随机数,作为choose
}
public void actionPerformed(ActionEvent ae)
{
String s;
s=ae.getActionCommand();
if (s.equalsIgnoreCase("Reset"))
{ // compute();
choose=(int)Math.floor(Math.random()*9); //算出0-9的随机数,作为choose
index=0; //reset 操作
re.reset();
repaint();
}
else if(s.equalsIgnoreCase("Guess"))
{ index=2; //guess操作
re.img=getImage(getDocumentBase(),"pic/s"+choose+".GIF");
re.getresult();
// System.out.print("123456798");
}
}
public void compute() //计算符合条件的数
{ int a,b,c;
for(int i=10;i<=99;i++)
{ a=i%10;
b=i/10;
c=i-a-b;
System.out.print(" ,"+c);
}
}
public void paint(Graphics g)
{
int num,a=20,b=40,all=0; //a是x轴,b是y轴
g.drawRect(65,75,600,450);
for(int j=1;j<=9;j++) //行
{
a=a+65;
for(int i=1;i<=11;i++) //列
{
if (all%9==0 & all<82 & all>8)
{ b=b+40;
g.drawString(""+all,a,b+5);
g.drawImage(img[choose],a+15,b,30,40,this);
}
else
{ b=b+40;
g.drawString(""+all,a,b+5);
while(true) //其它的图片不同于choose的图片
{ num=(int)Math.floor(Math.random()*9);
if (num!=choose)
break;
}
g.drawImage(img[num],a+15,b,30,40,this);
}
all=all+1;
}
b=40;
}
System.out.print("choose:"+choose);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -