public void actionPerformed(ActionEvent e) { if (e.getSource().equals(tankShootTheBomber)) { if (ta.getAmmo() > 0 && bo.isAlive()) { ta.shoot(bo); ta.setAmmo(ta.getAmmo() - 1); textI.setText(bo.toString() + "\n" + fs.toString()); textD.setText(ta.toString() + "\n" + in.toString()); if (bo.isAlive() == false && fs.isAlive() == false) { JOptionPane.showMessageDialog(null, "Invaders are dead game over"); System.exit(0); } } else JOptionPane.showMessageDialog(null, "Tank out of ammo or bomber is dead"); } else if (e.getSource().equals(infantryShootTheBomber)) { if (in.getAmmo() > 0 && bo.isAlive()) { in.shoot(bo); in.setAmmo(in.getAmmo() - 1); textI.setText(bo.toString() + "\n" + fs.toString()); textD.setText(ta.toString() + "\n" + in.toString()); if (bo.isAlive() == false && fs.isAlive() == false) { JOptionPane.showMessageDialog(null, "Invaders are dead game over"); System.exit(0); } } else JOptionPane.showMessageDialog(null, "Infantry out of ammo or bomber is dead"); } else if (e.getSource().equals(tankShootTheFootsoldier)) { if (ta.getAmmo() > 0 && fs.isAlive()) { ta.shoot(fs); ta.setAmmo(ta.getAmmo() - 1); textI.setText(bo.toString() + "\n" + fs.toString()); textD.setText(ta.toString() + "\n" + in.toString()); if (bo.isAlive() == false && fs.isAlive() == false) { JOptionPane.showMessageDialog(null, "Invaders are dead game over"); System.exit(0); } } else JOptionPane.showMessageDialog(null, "Tank out of ammo or Footsoldier is dead"); } else if (e.getSource().equals(infantryShootTheFootsoldier)) // { if (in.getAmmo() > 0 && fs.isAlive()) { in.shoot(fs); in.setAmmo(in.getAmmo() - 1); textI.setText(bo.toString() + "\n" + fs.toString()); textD.setText(ta.toString() + "\n" + in.toString()); if (bo.isAlive() == false && fs.isAlive() == false) { JOptionPane.showMessageDialog(null, "Invaders are dead game over"); System.exit(0); } } else JOptionPane.showMessageDialog(null, "Infantry out of ammo or Footsoldier is dead"); } /* else if(e.getSource().equals(reloadGood)) { good.setAmmo(10); text.setText(good.toString()+ "\n" + bad.toString() ); } else { bad.setAmmo(10); text.setText(good.toString()+ "\n" + bad.toString() ); }*/ }