Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

FightersUniverse
Monday, November 19th, 2007 at 8:04:25am MST 

  1. import java.util.Random;
  2.  
  3. public class FightersUniverse{
  4.         static Player players[] = new Player[4];
  5.        
  6.         public static void main(String args[]) {
  7.                 Random randomP = new Random();
  8.                 //BossPlayer boss = new BossPlayer();
  9.                 //BossPlayer boss1, boss2;
  10.                 //String Player[] = {"Boss Ho Yin", "Boss Nicholas", "Justin", "Jenefer"};
  11.                 Player att;
  12.                 players[0] = new BossPlayer("Boss Ho Yin");
  13.                 players[1] = new BossPlayer("Boss Nicholas");
  14.                 players[2] = new Player("Justin");
  15.                 players[3] = new Player("Jenefer");
  16.                
  17.                 int roundnum = 0;
  18.                 do {
  19.                         roundnum++;
  20.                         System.out.println("Round " + roundnum);
  21.                         int roundAttacker, roundTarget;
  22.                        
  23.                         // draw Attacker and Victim
  24.                         roundAttacker = randomP.nextInt(players.length);
  25.                         do {
  26.                                 roundTarget = randomP.nextInt(players.length);
  27.                         } while (roundAttacker == roundTarget);
  28.                        
  29.                         // carry out fighting
  30.                         int attackSuccess = randomP.nextInt(2);
  31.                                
  32.                         if (attackSuccess == 0) {// 0 means win, 1 means lose
  33.                                 players[roundTarget].attack(players[roundAttacker]);
  34.                                 System.out.println(players[roundAttacker].getPlayerName()+" lose");
  35.                                 System.out.println(players[roundAttacker].getPlayerName() +"'s hp = "+ players[roundAttacker].power);
  36.                                 System.out.println(players[roundTarget].getPlayerName() +"'s hp = "+ players[roundTarget].power);
  37.                                 System.out.println();
  38.                         }
  39.                         else {
  40.                                 players[roundAttacker].attack(players[roundTarget]);
  41.                                 System.out.println(players[roundAttacker].getPlayerName()+" win");
  42.                                 System.out.println(players[roundAttacker].getPlayerName() +"'s hp = "+ players[roundAttacker].power);
  43.                                 System.out.println(players[roundTarget].getPlayerName() +"'s hp = "+ players[roundTarget].power);
  44.                                 System.out.println();
  45.                         }
  46.                        
  47.                 } while (!anyoneIsDead());
  48.                
  49.                 System.out.println();
  50.                 System.out.println("=== Game Over ===");
  51.                 System.out.println(players[0].playerName + " 's power is: " + players[0].power);
  52.                 System.out.println(players[1].playerName + " 's power is: " + players[1].power);
  53.                 System.out.println(players[2].playerName + " 's power is: " + players[2].power);
  54.                 System.out.println(players[3].playerName + " 's power is: " + players[3].power);
  55.                 //System.out.printf();
  56.                
  57.         }
  58.        
  59.         public static boolean anyoneIsDead() {
  60.                 return (players[0].isDead() || players[1].isDead() || players[2].isDead() || players[3].isDead());
  61.         }
  62. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation fantasy-obligation