Question: Create a GUI for your game. You are free in designing it the way you like. You need to submit your code and a pdf

Create a GUI for your game. You are free in designing it the way you like. You need to submit your code and a pdf of the different screen shots.

Must be able to:

1 vs 1 2 vs 2

You have the freedom to add other formations.

//The game code//

- BattleRoyale.java

package project3;

import project3.characters.Riot; import project3.characters.Carnage; import project3.characters.Spiderman; import project3.characters.Venom; import project3.characters.Character; import java.util.Random;

public class BattleRoyale {

// A method that counts the number of alive characters and return it. public static int numAlive(Character[] characters) { int count = 0; // initialize count to 0 // for loop over the array of characters for(int i=0;i 1) { attackerIdx = ran.nextInt(characters.length); // randomly generate the attacker index // a loop that continues until the character at attacker index is alive while(!characters[attackerIdx].isAlive()) attackerIdx = ran.nextInt(characters.length); // randomly generating the other character index otherIdx = ran.nextInt(characters.length); // loop that continues until the character at other index is alive and the indices of attacker and other is not the same while((attackerIdx == otherIdx) || (!characters[otherIdx].isAlive())) { otherIdx = ran.nextInt(characters.length); } // displaying the details of who attacked whom System.out.println(characters[attackerIdx].getName()+" attacked "+characters[otherIdx].getName()); characters[otherIdx].hit(characters[attackerIdx].attack()); // attack // display the updated health of the character who was attacked System.out.println(characters[otherIdx].getName()+" health is: "+characters[otherIdx].getHealth()+" "); } // displaying the characters at the end of the battle System.out.println(" Characters at the end of Battle Royale: "); for(int i=0; i

} //End of BattleRoyale class.

- Character.java

package project3.characters;

public abstract class Character {

// The Name of the charcter protected String name; // The Strength of the charcter protected int strength; //The Health of the charcter protected int health;

// Instantiates a new Character public Character(String name) { this.name = name; }

// Gets name of the charcter public String getName() { return name; }

// Gets strength of the charcter. public int getStrength() { return strength; }

// Gets health of the charcter public int getHealth() { return health; }

// Attack int public abstract int attack();

//Hit / damage

public abstract void hit(int points);

// Is alive boolean public abstract boolean isAlive();

// printing @Override public String toString() { return "Name: " + name + ", Strength: " + strength + ", Health: " + health ; } }

- Venom.java

package project3.characters;

public class Venom extends Character {

public Venom(String name) { super(name); this.health = 100; this.strength = 15; // more powerful to attack }

@Override public int attack() { return strength; }

@Override public void hit(int points) { this.health -= points; }

@Override public boolean isAlive() { return health >= 0; }

@Override public String toString() { return "[ Class: Venom, "+super.toString()+" ]"; } }

- Spiderman.java

package project3.characters;

public class Spiderman extends Character {

public Spiderman(String name) { super(name); this.health = 100; this.strength = 13; }

@Override public int attack() { return strength; }

@Override public void hit(int points) { this.health -= points; }

@Override public boolean isAlive() { return health>=0; }

@Override public String toString() { return "[ Class: Spiderman, "+super.toString()+" ]"; } }

- Riot.java

package project3.characters;

public class Riot extends Character {

public Riot(String name) { super(name); this.health = 100; this.strength = 20; // super powerful to attack }

@Override public int attack() { return strength; }

@Override public void hit(int points) { this.health -= points; }

@Override public boolean isAlive() { return health>=0; }

@Override public String toString() { return "[ Class: Riot, "+super.toString()+" ]"; } }

- Carnage

package project3.characters;

public class Carnage extends Character {

public Carnage(String name) { super(name); this.health = 100; this.strength = 15; // more powerful to attack }

@Override public int attack() { return strength; }

@Override public void hit(int points) { this.health -= points; }

@Override public boolean isAlive() { return health >= 0; }

@Override public String toString() { return "[ Class: Carnage, "+super.toString()+" ]"; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!