- 私の
- 2007年 12月 11日 火曜日 23:31:52 MDT
- //Java Fighters Universe v2007
- //the second homework_ism001
- //by LAW MEI KWAN 8048955
- //2007-12-10
- import java.util.Random;// program class Ramdom number genarator
- public class FightersUniverse
- {
- Player players[];
- Random generator;
- private int target=0,attacker=0;
- private int r=0;
- private int deadNumber=0;
- private static final int TOTAL_PLAYERS=4;
- public FightersUniverse()
- {
- generator=new Random();
- players=new Player[TOTAL_PLAYERS];
- players[0]=new BossPlayer("Boss Rain");
- players[1]=new BossPlayer("Boss Elsa");
- players[2]=new BossPlayer("Andy");
- players[3]=new BossPlayer("Peter");
- }
- //method of attack
- public void Attack(){
- do
- {
- attacker=generator.nextInt(TOTAL_PLAYERS);
- target=generator.nextInt(TOTAL_PLAYERS);
- //choose another attacker if he/she is dead
- while (players[attacker].isDead)
- {
- attacker=generator.nextInt(TOTAL_PLAYERS);
- }
- //choose another target if he/she is dead or attacker
- while (target==attacker || players[target].isDead)
- {
- target=generator.nextInt(TOTAL_PLAYERS);
- }
- r++;
- players[attacker].r=r;
- //attacker attack target
- players[attacker].Attack(players[target]);
- if (players[target].isDead || players[attacker].isDead)
- deadNumber++;//incrase the dead number
- }while(deadNumber<TOTAL_PLAYERS-1);//end while
- System.out.println("");
- System.out.println("><~~~~> Game Over <~~~~><");
- for (int i=0;i<TOTAL_PLAYERS;i++)
- {
- System.out.printf("%s 's power = %d \n",players[i].getPlayerName(),players[i].getPlayerPower());
- }
- }//end attack
- //method of main
- public static void main(String argv[])
- {
- FightersUniverse main=new FightersUniverse();
- main.Attack();
- }//end main
- }//end class FightersUniverse
advertising
ポストを更新
このポストは更新できる、または、新しいポストを作成。
You may also comment on this post.
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.