public static void main(String[] args) { Tank tank = new Tank(Color.BLACK, 10, 100); T34 t34 = new T34(Color.BLACK, 5, 50); Bt7 bt7 = new Bt7(Color.GREEN, 4, 65); Tiger tiger = new Tiger(Color.BROWN, 3, 45); System.out.println(tank.toString() + " " + tank.move()); System.out.println(t34.toString() + " " + t34.move()); System.out.println(bt7.toString() + " " + bt7.move()); System.out.println(tiger.toString() + " " + tiger.move()); }
public void draw(Graphics g) { if (!live) { if (!good) { tc.tanks.remove(this); } return; } Color c = g.getColor(); if (good) g.setColor(Color.RED); else g.setColor(Color.BLUE); g.fillOval(x, y, WIDTH, HEIGHT); g.drawString("id:" + id, x, y - 10); g.setColor(c); switch (ptDir) { case L: g.drawLine(x + WIDTH / 2, y + HEIGHT / 2, x, y + HEIGHT / 2); break; case LU: g.drawLine(x + WIDTH / 2, y + HEIGHT / 2, x, y); break; case U: g.drawLine(x + WIDTH / 2, y + HEIGHT / 2, x + WIDTH / 2, y); break; case RU: g.drawLine(x + WIDTH / 2, y + HEIGHT / 2, x + WIDTH, y); break; case R: g.drawLine(x + WIDTH / 2, y + HEIGHT / 2, x + WIDTH, y + HEIGHT / 2); break; case RD: g.drawLine(x + WIDTH / 2, y + HEIGHT / 2, x + WIDTH, y + HEIGHT); break; case D: g.drawLine(x + WIDTH / 2, y + HEIGHT / 2, x + WIDTH / 2, y + HEIGHT); break; case LD: g.drawLine(x + WIDTH / 2, y + HEIGHT / 2, x, y + HEIGHT); break; } move(); }