a pastebin project

Mine

  1. //Java Fighters Universe v2007
  2. //the second homework_ism001
  3. //by LAW MEI KWAN 8048955
  4. //2007-12-10
  5.  
  6. import java.util.Random;// program class Ramdom number genarator
  7.  
  8. public class FightersUniverse
  9. {
  10.         Player players[];
  11.         Random generator;
  12.         private int target=0,attacker=0;
  13.         private int r=0;
  14.         private int deadNumber=0;
  15.         private static final int TOTAL_PLAYERS=4;
  16.        
  17. public FightersUniverse()
  18.         {
  19.                 generator=new Random();
  20.                 players=new Player[TOTAL_PLAYERS];
  21.                 players[0]=new BossPlayer("Boss Rain");
  22.                 players[1]=new BossPlayer("Boss Elsa");
  23.                 players[2]=new BossPlayer("Andy");
  24.                 players[3]=new BossPlayer("Peter");
  25.         }
  26.        
  27. //method of attack
  28. public void Attack(){
  29.        
  30.       do
  31.         {
  32.                
  33.                 attacker=generator.nextInt(TOTAL_PLAYERS);
  34.                 target=generator.nextInt(TOTAL_PLAYERS);
  35.                
  36.                 //choose another attacker if he/she is dead
  37.                 while (players[attacker].isDead)
  38.                 {
  39.                         attacker=generator.nextInt(TOTAL_PLAYERS);
  40.                 }
  41.  
  42.                 //choose another target if he/she is dead or attacker
  43.                 while (target==attacker || players[target].isDead)
  44.                 {
  45.                         target=generator.nextInt(TOTAL_PLAYERS);
  46.                 }
  47.  
  48.                 r++;
  49.                 players[attacker].r=r;
  50.  
  51.                 //attacker attack target
  52.                 players[attacker].Attack(players[target]);
  53.  
  54.                 if (players[target].isDead || players[attacker].isDead)
  55.                 deadNumber++;//incrase the dead number
  56.  
  57.         }while(deadNumber<TOTAL_PLAYERS-1);//end while
  58.        
  59.                 System.out.println("");
  60.         System.out.println("><~~~~> Game Over <~~~~><");
  61.  
  62.         for (int i=0;i<TOTAL_PLAYERS;i++)
  63.         {
  64.                 System.out.printf("%s 's power = %d \n",players[i].getPlayerName(),players[i].getPlayerPower());
  65.         }
  66.  
  67. }//end attack
  68.                
  69.        
  70. //method of main       
  71. public static void main(String argv[])
  72.         {
  73.                 FightersUniverse main=new FightersUniverse();
  74.                 main.Attack()
  75.         }//end main
  76.  
  77.  
  78.  
  79. }//end class FightersUniverse

advertising

Create a Paste

Please enter your new post below (or upload a file instead):





Please note that information posted here will not expire by default. If you 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.

fantasy-obligation