- Unnamed
- Monday, November 19th, 2007 at 6:20:50am MST
- import java.util.Random;
- public class FightersUniverse
- {
- Player players[];
- Random generator;
- //define how many players in the battle
- private static final int MAX_PLAYERS_SIZE=4;
- private int target=0,attacker=0;
- //identify which round is it
- private int Round=0;
- //identify how many players is already died
- private int deadNumber=0;
- public FightersUniverse()
- {
- players=new Player[MAX_PLAYERS_SIZE];
- //call 4 players(Object) to this battle
- players[0]=new BossPlayer("Boss Florence");
- players[1]=new BossPlayer("Boss Janice");
- players[2]=new Player("Potato HoYin");
- players[3]=new Player("Potato Justin");
- }
- public void Attack()
- {
- do
- {
- //use a random number (0-MAX_PLAYERS_SIZE) for attacker and target
- attacker=generator.nextInt(MAX_PLAYERS_SIZE);
- target=generator.nextInt(MAX_PLAYERS_SIZE);
- //if the attacker is dead then choose another one
- while (players[attacker].isDead)
- {
- attacker=generator.nextInt(MAX_PLAYERS_SIZE);
- }
- //if the target is dead or he is attacker then choose another one
- while (target==attacker || players[target].isDead)
- {
- target=generator.nextInt(MAX_PLAYERS_SIZE);
- }
- Round++;
- players[attacker].Round=Round;
- //attacker attack target
- players[attacker].Attack(players[target]);
- if (players[target].isDead || players[attacker].isDead)
- deadNumber++;
- }
- while
- (deadNumber<MAX_PLAYERS_SIZE-1);
- for (int i=0;i<MAX_PLAYERS_SIZE;i++)
- {
- }
- }
- {
- FightersUniverse main=new FightersUniverse();
- main.Attack();
- }
- }
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.
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.