????? Java?棨????GUI??
???????????? ???????[ 2014/7/22 10:34:35 ] ????????????? Java
??????????д??С??????????????????????????????????????????????????н??л???????壬?????????????????????????????
???????????£?
import java.awt.*;
import java.awt.event.*;
import java.util.List;
import java.util.ArrayList;
public class SnakeClient extends Frame {
/**
* ????????????
* ???????????????????
* 0.4????????????
*/
private static final long serialVersionUID = 1L;
private static int WIDTH=406??HEIGHT=428;
List<Snake> snakes=new ArrayList<Snake>();
List<Egg> eggs=new ArrayList<Egg>();
Snake s=new Snake(3??25??true??0??this);
Snake body1=new Snake(3??45??false??1??this);
Snake body2=new Snake(3??65??false??2??this);
boolean eat=false;
Egg e=new Egg();
public static void main(String []args){
SnakeClient sc=new SnakeClient();
sc.launchFrame();
}
void launchFrame(){
this.setBounds(100?? 100?? WIDTH?? HEIGHT);
this.setVisible(true);
this.setResizable(false);
this.addWindowListener(new WinCloseMonitor());
// bug2 :???????????????·????????
this.addKeyListener(new KeyMonitor());
new Thread(new MyThread()).start();
snakes.add(s);
eggs.add(e);
}
class WinCloseMonitor extends WindowAdapter{
// bug1 ???windowClosing д??WindowClosing
// ?????д???????????????Eclipse????д????
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
public void paint(Graphics g){
for(int i=0;i<snakes.size();i++){
Snake sn=snakes.get(i);
if(s.hitSnake(sn)&&!sn.head){
snakes.removeAll(snakes);
return;
}
sn.draw(g);
if(sn.eatEgg(e)) eat=true;
}
if(eat){
snakes.add(new Snake(snakes.get(snakes.size()-1).oldX??snakes.get(snakes.size()-1).oldY??
false??snakes.size()??this));
eat=false;
eggs.remove(e);
e=new Egg();
eggs.add(e);
}
e.draw(g);
}
class MyThread implements Runnable{
@Override
public void run() {
while(true){
repaint();
try {
Thread.sleep(350);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class KeyMonitor extends KeyAdapter{
@Override
public void keyPressed(KeyEvent e) {
s.keyPressed(e);
}
}
}
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Java???????????Щ???????????????Java????????????????Java?б???Map????????Java Web???????????????Java??????????????д?????Java????????7???????????????????????(java .net ?????)???Java??????????Python??????Java webdriver??λ????????′????е?????Java??д??????????????????Java???????????????JavaScript????????????Java?????????????????? Java???????10??????????????Java?м????????????????java???????ü???????????м???????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????