import java.util.Random; public class FightersUniverse{ static Player players[] = new Player[4]; public static void main(String args[]) { Random randomP = new Random(); //BossPlayer boss = new BossPlayer(); //BossPlayer boss1, boss2; //String Player[] = {"Boss Ho Yin", "Boss Nicholas", "Justin", "Jenefer"}; Player att; players[0] = new BossPlayer("Boss Ho Yin"); players[1] = new BossPlayer("Boss Nicholas"); players[2] = new Player("Justin"); players[3] = new Player("Jenefer"); int roundnum = 0; do { roundnum++; System.out.println("Round " + roundnum); int roundAttacker, roundTarget; // draw Attacker and Victim roundAttacker = randomP.nextInt(players.length); do { roundTarget = randomP.nextInt(players.length); } while (roundAttacker == roundTarget); // carry out fighting int attackSuccess = randomP.nextInt(2); if (attackSuccess == 0) {// 0 means win, 1 means lose players[roundTarget].attack(players[roundAttacker]); System.out.println(players[roundAttacker].getPlayerName()+" lose"); System.out.println(players[roundAttacker].getPlayerName() +"'s hp = "+ players[roundAttacker].power); System.out.println(players[roundTarget].getPlayerName() +"'s hp = "+ players[roundTarget].power); System.out.println(); } else { players[roundAttacker].attack(players[roundTarget]); System.out.println(players[roundAttacker].getPlayerName()+" win"); System.out.println(players[roundAttacker].getPlayerName() +"'s hp = "+ players[roundAttacker].power); System.out.println(players[roundTarget].getPlayerName() +"'s hp = "+ players[roundTarget].power); System.out.println(); } } while (!anyoneIsDead()); System.out.println(); System.out.println("=== Game Over ==="); System.out.println(players[0].playerName + " 's power is: " + players[0].power); System.out.println(players[1].playerName + " 's power is: " + players[1].power); System.out.println(players[2].playerName + " 's power is: " + players[2].power); System.out.println(players[3].playerName + " 's power is: " + players[3].power); //System.out.printf(); } public static boolean anyoneIsDead() { return (players[0].isDead() || players[1].isDead() || players[2].isDead() || players[3].isDead()); } }