java上机考试.docVIP

  • 19
  • 0
  • 约1.47千字
  • 约 3页
  • 2018-02-24 发布于河南
  • 举报
java上机考试

JAVA上机考试题目 用JAVA程序设计语言设计一个子弹类,要求带构造函数进行初始化,参数里面持有tc的引用,同时带有自身的mydrew()方法。(50分) 评分标准 :(程序书写规范20分,程序正确性30分) public class TankClient { public static void main(String[] args) { } } ***************************************************************** import java.awt.Color; import java.awt.Graphics; public class Missile { int x,y; TankClient tc; boolean missilelife = true; public Missile(int x, int y, TankClient tc, boolean missilelife) { super(); this.x = x; this.y = y; this.tc = tc; this.missilelife = missilelife; } public void mydraw(Graphics g){ if(missilelife==false){ return; } Color c = g.getColor(); g.setColor(Color.black); g.fillOval(x-3, y-4, 15,15); g.setColor(c); } } JAVA语言设计完成一个物体的边界和另外一个物体边界相交的判断,方法名统一为hit();当两个物体碰撞时,要求两个物体的boolean变量均进行改变。(50分) 评分标准 :(程序书写规范20分,程序正确性30分) import java.awt.Rectangle; public class Object { boolean objectlife = true; boolean object_charter; public Rectangle getRect() { return null; } } ********************************************************************* import java.awt.Rectangle; public class Hit { int x,y; boolean life = true; public Rectangle getRect(){ return new Rectangle(this.x,this.y,15,15); } boolean charter; public boolean hit(Object t){ if(t.objectlife==truethis.getRect().intersects(t.getRect()) this.charter!=t.object_charter){ this.life = false; t.objectlife = false; return true; } else{ return false; } } public static void main(String[] args) { } }

文档评论(0)

1亿VIP精品文档

相关文档