CSC241: Homework 2
In this homework we extend the hierarchy of classes pertinent to the project. Expand upon your previous homework with the following:
- A Room class that has references to four other Room objects, respectively the neigbors to the north, south, east, and west.
- The Room class should also have a 10-cell array that will hold Creature references. This array substitutes the Animal array in the Room class from Homework 1; change the Room class as necessary.
- Finally, the Room class should have a String field that holds its state (as in "clean" or "dirty" or "half-dirty"), another String field that holds the name of the Room, and a third String field that holds the description of the Room.
- A hierarchy of four classes: Creature, Animal, NPC, and PC. Creature is the parent of the rest.
- All Creatures should contain a reference to the Room they are in. Also, all Creatures should be capable of modifying the state of the Room they are in. In addition, all Creatures have a String name and a String description, while the PC has an additional parameter - int respect that is initialized to 40. Finally, all Creatures should be capable of being notified of a state change in the Room they are in, and react accordingly (see the project description). This means that Creatures should be capable of leaving the Room they are in, entering another, looking at its state, etc. 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 these methods; this is design. You need the method signatures, and maybe comments about the reason a method signature exists. You will provide the implementations in Homework 4.
- You will need to change the classes you wrote in Homework 1, as already described for the Room class. Think about the appropriate places for all the new functionality, as well as the Homework 1 functionality, now that you have a hierarchy of classes.
You will be evaluated on supplying well-designed classes that provide the above functionality.