Hi There!

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

Assignment 6

In this assignment you will implement a new feature of your choosing, along with some cheat codes in your which will allow you to see the contents of rooms you are not currently in.

Part 1 – New Feature

Come up with a new spooky feature to be added to your game. In a text document, write:

  • Your name
  • The feature you are planning to add
  • How your feature works and how it integrates with your existing game from a user perspective. (Think about how the user’s experience changes with this feature – are there new options? What do they do? Is there new output? What does that look like? Essentially, write one or more small “scripts” for how the user will use your feature and what expected input/output looks like.)
  • What new code / modifications to existing code will you need to write, and where will you need to write it? Will the input XML file need to change? If so, how? If you have design documents for your project it might be a good time to reference them!

(Note, if you came to class on Halloween, you will already have some experience doing this – you can use the feature you developed then or a new one!)

Implement your new feature. If you need to modify the input xml file, please modify the sample one I provided and submit it alongside your game and the above described text document. Write JUnit tests to ensure your feature works as designed.

Part 2 – Cheat Codes

To implement cheat codes you will make use of the BST which we have been writing in class. Specifically, you should:

  • Begin with the BinarySearchTree.java file from class (to appear on the course github once we are ready).
  • Modify the Node class to have both a key and a value. The key is used to find the Node, the value is what is returned when the node is found. (Note that while the key must implement Comparable, the value need not.) Modify the BinarySearchTree class as necessary so that insertion takes both a key and value, and so that the value is returned from a find operation on the key.
  • Implement the remove method for BSTs as discussed in class.
  • Write some JUnit tests to ensure your BST is working as you expect. Be sure to test insert, find, and remove.

Once you’ve finished with your BST, use it to store Rooms in your game. Use the room name as the key, and the Room object itself as the value. This will allow you to look up a room by its name!

You will then modify your Player class to accept the following commands:

cheatmode – enables the below two options.
look:[roomname] – prints out the contents of [roomname] by looking up the Room in the BST using the search method.
look:all – prints out the contents of all rooms, printed in alphabetical order by room name using an in-order traversal of the BST.
nocheatmode – disallows the use of the above two options.

Note, if you used a two-step process to interact with Items, you may use that same process here to maintain consistency.