You are part of a team writing classes for the different game objects in a video game. In this assessment you are given a superclass (Human.java), two subclasses (Warrior.java and Wizard.java) and a test application (TestGameObjects.java). Both the Warrior and the Wizard classes need to be able to calculate stealth. This needs to be done in the method getStealth. This method has an integer parameter (dexterity) and returns an integer. Refer to the test application to see how the method is used. The Warrior and Wizard classes calculate stealth differently: The Warrior's stealth is equal to dexterity times strength (dexterity * strength) while the Wizard's stealth is equal to three times dexterity times intelligence (3 * dexterity * intelligence). You need to write an interface with the method getStealth, and then modify the superclass and subclasses to implement this interface. You also need to test the validity of the object ID. The object ID must consist of the character 'W' followed by  4 digits (eg.: "W1234"). If the object ID is invalid you need to throw an InvalidObjectIDException. You need to write the exception class. It must be an unchecked exception. Lastly you need to write a test application to test the validity testing. In this application you must create objects with

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

java

You are part of a team writing classes for the different game objects in a video game.

In this assessment you are given a superclass (Human.java), two subclasses (Warrior.java and Wizard.java) and a test application (TestGameObjects.java). Both the Warrior and the Wizard classes need to be able to calculate stealth. This needs to be done in the method getStealth. This method has an integer parameter (dexterity) and returns an integer. Refer to the test application to see how the method is used. The Warrior and Wizard classes calculate stealth differently: The Warrior's stealth is equal to dexterity times strength (dexterity * strength) while the Wizard's stealth is equal to three times dexterity times intelligence (3 * dexterity * intelligence). You need to write an interface with the method getStealth, and then modify the superclass and subclasses to implement this interface.

You also need to test the validity of the object ID. The object ID must consist of the character 'W' followed by  4 digits (eg.: "W1234"). If the object ID is invalid you need to throw an InvalidObjectIDException. You need to write the exception class. It must be an unchecked exception. Lastly you need to write a test application to test the validity testing. In this application you must create objects with the following invalid IDs: "12345", "W12345" and "W1b23". Each object must be created in a separate try-catch block.

 

public class TestGameObjects { public static void main(String[] args) { Warrior w1 = new Warrior("W1234", 25); Wizard z1 = new Wizard("W2467", 35); System.out.println("Warrior w1 with dexterity 50 has stealth: " + w1.getStealth(50)); System.out.println("Wizard z1 with dexterity 25 has stealth: " + z1.getStealth(25)); } }

 

public class Warrior extends Human { private int strength; public Warrior() { this("W0000",1); } public Warrior(String id, int strength) { super(id); setStrength(strength); } public void setStrength(int s) { strength = s; } public int getStrength() { return strength; } }

public class Wizard extends Human { private int intelligence; public Wizard() { this("W0000",1); } public Wizard(String id, int intel) { super(id); setIntelligence(intel); } public void setIntelligence(int intel) { intelligence = intel; } public int getIntelligence() { return intelligence; } }

 

Public class Human { private String objectID; public Human() { this("W0000"); } public Human(String id) { setObjectID(id); } public void setObjectID(String id) { objectID = id; } public String getObjectID() { return objectID; } }

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY