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

Unnamed
Monday, November 19th, 2007 at 6:20:50am MST 

  1. import java.util.Random;
  2. public class FightersUniverse
  3. {
  4.         Player players[];
  5.         Random generator;
  6.         //define how many players in the battle
  7.         private static final int MAX_PLAYERS_SIZE=4;
  8.         private int target=0,attacker=0;
  9.         //identify which round is it
  10.         private int Round=0;
  11.         //identify how many players is already died
  12.         private int deadNumber=0;
  13.         public FightersUniverse()
  14.         {
  15.                 generator=new Random();
  16.                 players=new Player[MAX_PLAYERS_SIZE];
  17.                 //call 4 players(Object) to this battle
  18.                 players[0]=new BossPlayer("Boss Florence");
  19.                 players[1]=new BossPlayer("Boss Janice");
  20.                 players[2]=new Player("Potato HoYin");
  21.                 players[3]=new Player("Potato Justin");
  22.         }
  23.        
  24.         public void Attack()
  25.         {
  26.         do
  27.         {
  28.                 //use a random number (0-MAX_PLAYERS_SIZE) for attacker and target
  29.                 attacker=generator.nextInt(MAX_PLAYERS_SIZE);
  30.                 target=generator.nextInt(MAX_PLAYERS_SIZE);
  31.                 //if the attacker is dead then choose another one
  32.                 while (players[attacker].isDead)
  33.                 {
  34.                         attacker=generator.nextInt(MAX_PLAYERS_SIZE);
  35.                 }
  36.                 //if the target is dead or he is attacker then choose another one
  37.                 while (target==attacker || players[target].isDead)
  38.                 {
  39.                         target=generator.nextInt(MAX_PLAYERS_SIZE);
  40.                 }
  41.                 Round++;
  42.                 players[attacker].Round=Round;
  43.                 //attacker attack target
  44.                 players[attacker].Attack(players[target]);
  45.                 if (players[target].isDead || players[attacker].isDead)
  46.                 deadNumber++;
  47.         }
  48.         while
  49.         (deadNumber<MAX_PLAYERS_SIZE-1);
  50.  
  51.         System.out.println("----Game Over-----");
  52.         for (int i=0;i<MAX_PLAYERS_SIZE;i++)
  53.         {
  54.                 System.out.printf("**** %s power = %d \n",players[i].getName(),players[i].getPower());
  55.         }
  56.         }
  57.                
  58.        
  59.        
  60.         public static void main(String argv[])
  61.         {
  62.                 FightersUniverse main=new FightersUniverse();
  63.                 main.Attack()
  64.         }
  65.  
  66.  
  67.  
  68. }

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