Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-------------------------------------------------------------------------------------------------------------------------- public class TestPhase3 { public static void main(String[] args) { Tile[][] board = { {new Wall(), new Wall(), new Wall(), new Wall(), new Wall(),

image text in transcribed

--------------------------------------------------------------------------------------------------------------------------

public class TestPhase3 {

public static void main(String[] args) { Tile[][] board = { {new Wall(), new Wall(), new Wall(), new Wall(), new Wall(), new Wall()}, {new Wall(), new OpenSpace(new Trap()), new OpenSpace(new Amulet()), new OpenSpace(), new OpenSpace(new Troll()), new Wall()}, {new Wall(), new OpenSpace(new Trap()), new OpenSpace(new HealthPotion()), new OpenSpace(new Player()), new OpenSpace(), new Wall()}, {new Wall(), new Wall(), new Wall(), new Wall(), new Wall(), new Wall()}, }; for (Tile[] row : board) { for (Tile t: row) { System.out.print(t.getSymbol()); } System.out.println(); }

}

}

--------------------------------------------------------------------------------------------------------------------------

Phase 2:

https://www.chegg.com/homework-help/questions-and-answers/public-class-testphase2-public-static-void-main-string-args-tile-board-new-wall-new-wall-n-q27357620

Phase 3: Combatants Combatants are the characters on the board. There is always exactly one player, and zero or more enemies. Both havee "hit points" (the amount of health the combatant has). When the hit points become zero or lower, the combatant is removed from the board. Health potions can increase the player's hit points, while traps lower the player's hit points Combatants have attacks which vary in strength. There are minimum and maximum attack values. Each time an attack is made, a new random attack value between the minimum and maximum is returned. This amount of health is removed from the combatant that is being attacked Define an abstract Combatant class that is a subclass of Content.It should have: Three instance variables: int values for the health, and minimum and maximum attack values A constructor which accepts parameters of type (String, int, int, int) which are the symbol, health, minimum, and maximum attack points, in that order . . . Three methods o int getHP) - returns the current number of hit points (health) o int doAttack() - return a random number between the minimum and maximum attack values, inclusive. Investigate Math.random() to do this. o void changeHP() - add this amount to the combatant's hit points. The number could be negative. Define three subclasses of Combatant: Player: represented by an @" on the board, this is the playing piece the user will be able to move. The player should start with 100 hit points, and have a minimum attack value of 5, and a maximum of 10 Trol1: represented by a "t" on the board. Trolls should start with 10 hit points, and have a minimum attack value of 1, and a maximum of 10 GreaterTroll, which is a subclass of Troll: Greater Trolls have double the hit points of Trolls, attack twice not once, and are represented by a "T" on the board. The constructor of GreaterTroll should call the constructor of Trol1, then modify the hit points. The doAttack() method of GreaterTroll should call the doAttack() method in Troll twice, and return the total damage These three subclasses should have only a no-parameters constructor * Add toString() methods to the Combatant class, and all of its subclasses, that simply returns the class name You can test your class with TestPhase3.java. You should get the output shown below #Ah@.#

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions