Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

Assignment 2

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 four classes describing the entities which may be in a Room: Creature, Animal, NPC, and PC. Creature is the parent of the others.
  • Rooms contain Creatures, not only Animals, so modify the Room class to contain a 10-cell array of Creatures, instead of Animals. Change the Room class as necessary to accommodate this change.
  • Rooms can have three states – clean, dirty, and half-dirty. Create a public enum called State inside the Room class with these options.
  • The Room class should have a State variable that holds its state, and a String variable that holds the description of the Room (in addition to the name field which is already present).
  • Creatures have a reference to the Room they are in, and all Creatures should be capable of modifying the state of the Room they are in.
  • Creatures have a String name and a String description, while the PC has an additional parameter – int respect that is initialized to 40.

Also perform the following design:

  • All Creatures will eventually need to 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 comments about the reason a method signature exists. 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 Homework 1 functionality, now that you have a hierarchy of classes (e.g., what happens to the functionality that was previously in Animal?).

You will be evaluated on supplying well-designed classes that provide the above functionality.