- FightersUniverse.java
- Sunday, December 16th, 2007 at 6:22:10pm MST
- import java.util.Random;
- public class FightersUniverse {
- public static boolean isAllAlive( Player player[] ){
- for( Player p: player )
- if(p.isDead()) return false;
- return true;
- }
- int counter=0;
- int one, two;
- final int N = 4;
- // Define new players
- Player player[] = {
- new Player("Ho Yin"),
- new Player("Justin"),
- new BossPlayer("Boss Janice"),
- new BossPlayer("Boss Florence")
- };
- do {
- do { // Loop until valid players are selected
- one = generator.nextInt(N);
- two = generator.nextInt(N);
- } while ( player[one].isDead() || player[two].isDead() || one==two );
- // Remember the original power
- int onePower = player[one].getPower();
- int twoPower = player[two].getPower();
- // Attack!
- player[one].attack(player[two]);
- // Print the change in power after the attack
- System.out.println("*** " + player[one].getName() + ": " + onePower + " -> " + player[one].getPower());
- System.out.println("*** " + player[two].getName() + ": " + twoPower + " -> " + player[two].getPower());
- } while ( isAllAlive( player ) ); // Loop until any one is dead
- for( Player p: player ){
- }
- }
- }
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.