Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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?

Java, Programming

  • Category:- Java
  • Reference No.:- M92705449
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Java

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As