Create a new project named coliseum

Assignment Help JAVA Programming
Reference no: EM131877100

Application Assignment

1. Create a new project named Coliseum.

2. The idea of this project is to simulate a fight per turns between two warriors.

3. Create a new abstract class named Warrior, in a package named coliseum.

4. In the abstract class Warrior

a. Create a private integer variable named health, with a hard-coded value of 30. All warriors have 30 health points.

b. Create a private integer variable named attack. The attack points of each type of warrior are different.

c. Create a private integer variable named defense. The defense points of each type of warrior are different.

d. Create a setter and a getter for each variable. In eclipse, a symbol appears at the beginning of the line, where a variable was created. If you click on it, it will show more options such as automatically create a setter and a getter for that variable.

e. Create another public method named attack. This method returns the value of the damage that the opponent will receive. This method receives the opponent (Warrior) as parameter. The damage is equal to "the attack points of the current warrior' minus "the defense points of the opponent". If the damage is a negative value, then set damage to 0. Finally, return the damage value.

f. Create another public method named receivesDamage. This method does not return anything. This method receives the damage (integer value) as parameter. The health points of the current warrior is updated to "the health points of the current warrior" minus "the damage". If the resulting health points is a negative value, then set health points to 0.

g. Create a public abstract no-argument method named getReady. This method sets the attack points and defense points of a warrior.

5. Create a subclass of Warrior named Spartan

a. Override the method getReady

i. Call the method setAttack with a value of 6. This will set the attack points of all Spartans to 6.
ii. Call the method setDefense with a value of 5. This will set the defense points of all Spartans to 5.

6. Create a class with a main method named Arena

a. Copy the following code to the main method

Warrior defender = new Spartan();
Warrior attacker = new Spartan();
do {
// Switch warriors' roles
Warrior temporal = attacker;
attacker = defender;
defender = temporal;
// Get ready
defender.getReady();
attacker.getReady();
// Attack
defender.receivesDamage(attacker.attack (defender));
} while (defender.getHealth()>0);

7. Run your code.

8. It should compile and run. However, nothing is displayed.

9. Let's display some information about the fight.

a. In the method attack (no overriding), before returning the damage, display the attack points of the current warrior, and display the defense points of the other warrior.

i. System.out.println("Attack level: " +this.getAttack());
ii. System.out.println("Defense level: "+ otherWarrior.getDefense());

b. In the method receivesDamage (no overriding), display health points of the warrior after receiving damage.

i. System.out.println("Current health: " + this.getHealth());

10. Run your code.

11. It should compile and run. Information of the fight is displayed. However, it is not clear who is attacking and defending.

12. Let's add more information.

13. In class Warrior, add a new instance variable named name. Add the corresponding getter and setter.

14. Create a constructor in class Spartan which receives as an argument the name of the Spartan warrior and store it in the variable name.

15. Create a new interface named identifiable. A class which implements this interface must have a method to return a String value which represents the object.

a. Define a method named getldentifier. This method must return a String value.

16. Make the class Warrior implement the interface identifiable.

17. Add the public method getldentifier. This method will return the value of the variable name.

18. Call the method getldentifier in methods attack and receivesDamage, so they can display the identifiers of the warriors, for instance

Leonidas' Current Health: 1
Leonidas' Attack Level: 6
Stelios' Defense Level: 5
Stelios' Current Health: 0

19. Call the Spartan constructors with names for the warriors.

20. Run the program.

21. Create another type of warrior (subclass of warrior) named Gladiator. The defense points of a Gladiator are always 4. The attack points of a Gladiator are a random number between 1 and 10.

22. Spartan vs Gladiator. Who wins?

Reference no: EM131877100

Questions Cloud

Discuss about personality a product of western culture : How is our knowledge about personality a product of Western culture? That is, can we apply our personality theory to the rest of the world?
What is the probability that any given sales representative : What is the probability that any given sales representative will sign more than 30 new clients in a month? Answer to at least four decimal places.
How do american feel about voting rights today : Evidence overwhelming supports this factual claim. So how do American feel about voting rights today?
What are the sources of first solars competitive advantage : Global Enterprise and Competition MGMT.6910 - Is the solar industry an attractive industry? Why or why not? Be specific. Use Exhibit 9 to calculate ROA, ROIC
Create a new project named coliseum : Create a new project named Coliseum. Create a private integer variable named attack. The attack points of each type of warrior are different.
What is the probability that more than 10 parts : What is the probability that more than 10 parts will be defective? Answer to at least four decimal places.
Prepare all the journal entries for allen : Absolute Leasing, Inc. agrees to lease equipment to Allen, Inc. on January 1, 2012. Prepare all the journal entries for Allen, Inc. for 2012
How big will the ad-valorem tax need to be : If the government wants to collect from an ad-valorem tax levied on the consumers that will generate the same amount of tax revenue as a $5 specific tax
What is the general subject of the article : Political scientists are interested in examining one of the great puzzles of American democracy.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd