This assignment will extend the class hierarchy for the project, utilizing principles of object orientation as discussed in class. Expand upon your previous assignment by performing the following implementation:
- A Room class has references to four other Room objects, respectively the neighbors to the north, south, east, and west.
- There is a hierarchy of five classes describing the entities which may be in a Room: Character, Player, NPC, Adult, and Child. Character is the parent of Player and NPC; NPC is the parent of Adult and Child.
- Rooms contain Characters, not only Adults, so modify the Room class to contain an appropriately sized array of Characters, instead of Adults. Change the Room class as necessary to accommodate this change.
- Create a class called Item. Each Item has a name and description.
- Items can have one or more of three actions done to them – possess, shake, throw. Create a public enum called ItemActions inside the Item class with these options.
- The Item class should have an array of size 3 which contains ItemActions – these are the actions a particular Item instance can have done to it. ItemActions can be added to this array, but the array should never contain duplicates. We’ll need a way to check if an Item supports a specific ItemAction.
- All NPCs have an integer containing their level of scared-ness.
You should modify your Main class to update tests created in Assignment 1, and to add new ones to ensure new functionality is working as intended.
Also perform the following design:
- All Characters will eventually need to be capable of being notified of a haunting going on in the Room they are in, and react accordingly (see the project description). This means that Characters should be capable of leaving the Room they are in, entering another, checking of the room they enter needs cleaning up, etc. Items also must be manipulated to cause the haunting, resulting in the reaction of other Characters. Think carefully about the proper place for all that functionality, what are good ways to split it among the various classes, and in general about the proper design of the class hierarchy (what is abstract, what is final, etc). Note that you do not have to provide implementations for the methods in this design section. You need the method signatures or stubs and (detailed!) comments about the reason a method signature exists and how everything is intended to work together. You will provide the implementations in an upcoming assignment.
You will need to change the classes you wrote in Assignment 1. Think about the appropriate places for all the new functionality, as well as the Assignment 1 functionality, now that you have a hierarchy of classes (e.g., what happens to the functionality that was previously in Adult?).
You will be evaluated on the functionality and design supporting the above description.