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 some cheat codes in your game which will allow you to see the contents of rooms you are not currently in. To do so, you will make use of the BST which we have been writing in class. Specifically, you should:

  • Begin with the BST.java file from class.
  • Implement the Comparable interface in your Room class.
  • Make your BST (and BSTNode) generic using Java Generics, as we did for our Linked List.
  • Modify the BST’s insert and search methods to use the compareTo method provided by the Comparable interface.

At this point I recommend writing a small driver class to test your BST to ensure it works for all cases.

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.

Extra Credit: You may receive up to 20% extra credit on this assignment by implementing the Iterable and Iterator interfaces on your BST in an efficient manner. This should allow walking through the data structure in order using a simple for-each style loop from outside the BST. You may not copy the contents of the BST to a different data structure – it must be done in place.