d hierarchies that take advantage of object-oriented concepts to handle the different events and scenarios in your mansion. This will include a set of Rooms, Monsters, and a Player. Rooms in the mansion are arranged into a two-dimensional square grid. HauntedMansion models the arrangement, or floorplan, of rooms. A Player always begins in the middlemost Room of the mansion. An exit room will be specially designated. The Pla
Scooby and the Mystery Inc. gang are in a real pickle, or more accurately, you’ll be putting them in one! You will set the stage for their newest adventure, a text-based command-line adventure game, in which the gang must escape a HauntedMansion.
You will define several classes and hierarchies that take advantage of object-oriented concepts to handle the different events and scenarios in your mansion. This will include a set of Rooms, Monsters, and a Player.
Rooms in the mansion are arranged into a two-dimensional square grid. HauntedMansion models the arrangement, or floorplan, of rooms. A Player always begins in the middlemost Room of the mansion. An exit room will be specially designated. The Player can move left, right, up, or down one step (Room) during each round of the game. The Player begins the game with a level of courage (integer value). The Player wins the game if they find exit room while still having a level of courage above 0. If the player’s courage level ever goes to zero or a negative value, they immediately lose the game.
Unfortunately, some rooms in the Mansion contain some not-so-pleasant inhabitants! Whenever a Player enters a Room, they may encounter a Monster. A Monster encounter will take a toll on a Player’s courage. Monsters come in different varieties, and their respective effects on players will vary. You will have a base Monster class and some subclasses to create different types of Monsters.
While the scary monsters are there to thwart you, fortunately there will be Scooby Snacks in a few rooms to help you along the way. Moving into a room with Scooby Snacks boosts the Player’s courage.
The data members for your classes should be only accessible via appropriate setter and getter methods. You may create such getters and setters as needed, even if they are not explicitly specified. All explicitly described methods should be public unless otherwise stated, and you may create additional private helper methods wherever necessary. Similarly, all instance data should be private unless otherwise stated.
You will have to write many constructors throughout this assignment, and they won’t be explicitly detailed in this document. Instance data that’s expected to be provided to constructors is underlined. If an autograder checks for constructor headers, it will anticipate that constructor arguments are listed in the same top to bottom order shared in this document.
Ghoul.java
This class will represent a subset of Ghosts, the Ghoul, which has no unique attributes. Like Ghost, it should also have a fright factor of 10.
You should be able to instantiate a Ghoul object. Ghouls will have no unique behaviors, but will differ slightly from Ghosts:
- haunt
o This method should override the one in its parent class.
o A Ghoul will chase the Player out of the Room just as a Ghost does. You should not rewrite the code to do this (Hint: there’s a keyword you can use to access a parent’s implementation of a method).
o A Ghoul will also curse the doors shut so the Room it resides in cannot be re-entered.
You should update the Room it resides in to be locked. Then print out something like:
▪ The doors slam shut behind {player name}. It doesn’t seem like they can be reopened...
You should also provide a toString for a Ghoul, which should return some kind of spooky greeting describing itself and specifying what kind of monster it is.
Step by step
Solved in 3 steps with 1 images