Hi There!

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

Assignment 2

This assignment will flesh out 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:

  • Create a class called Door which has a name and description. Doors also have a reference to two Rooms (those on either side of the Door), and a variable to indicate whether or not the Door is locked.
  • A Room object has references to four Door objects, respectively the doors to the north, south, east, and west.
  • When a Room has one of its Doors set, the Door must set one of its two Room references. When a Door is added to a second Room, be sure the correct Room reference is updated in the Door!
  • There is a hierarchy of five classes describing the entities which may be in a Room: Character, Player, NPC, Guard, and Maid. Character is the parent of Player and NPC; NPC is the parent of Guard and Maid.
  • Rooms contain Characters, not only Guards, so modify the Room class to contain an ArrayList of Characters, instead of Guards. Change the Room class as necessary to accommodate this change.
  • Create a class called Item. Each Item has a name, description, and weight. Each Item may also be carry-able and/or hidden. Also create a subclass of Item called Key. Keys additionally have a String variable representing the name of the Door the Key is for.
  • Create an interface called Inspectable which declares the public String inspectString() method. Implement this interface in Item, Room, Door, and Character.

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 note that if you have comments from Assignment 1, be sure to implement those changes in Assignment 2 so you don’t lose points for them again!

Also perform the following design:

  • Examine the project description paying special attention to all of the things which need to happen when the player inspects something in the Room. In particular, you want to pay attention to how Guards and Maids might respond, and how the Player might end up back in the dungeon cell and lose some health. Think carefully about the proper place for all that functionality,  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 (commented out) 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 Guard?).

You will be evaluated on the functionality and design supporting the above description.