Hi There!

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

Assignment 3

Warning: You should expect to write at least 200 lines of code in this assignment, some of which will require a lot of thought. Do not wait until the last minute!

In this assignment we deal with XML input. Use the JDK SAX parser libraries to parse an input file and populate an object hierarchy out of the classes you created in Assignment 2 according to the contents of that file. An example file is located here. This file contains the proper tag names, attribute names, and hierarchy that will be encountered in all possible input files. This is only an example file – don’t hard code your program to depend on these rooms, items, etc. You will need to add an ArrayList of Items to the Room class and a way to add additional Items as you read them from the XML file. Items will need an ArrayList of sub-items (items located within/around other items) and a way to add them.

You may need to tweak your classes to make them easier to use with the data as it comes in from the XML file. For example, if your constructor for Door did not include whether it was locked, now is a good time to add that, add an instance field, and add a getter. Look for these things throughout your program!

Think carefully about linking the Room/Door objects with one another. You will have to store references to them in some external structure, so that you know which Room has already been created and grab a reference to it. You may want to make several passes over the XML file, or you may decide to use just one. It is up to you.

You can safely assume that the input file is well-formed according to the tag names in the example, and the project description. This means that the input file will never contain a “human” tag, for example, etc.

Once again you will modify your Main class to serve as a way to test your program. This time, the main method first asks the user for an input file name, and then proceeds to open that file and parse it as explained above. After everything is parsed, the main method should ask the user for a Room name, and then either output all the information for the respective Room (including name, description, names of neighboring Rooms, Characters and Items contained – with name and description for each Character and Item, Items should also note if they are hidden) or output “no such room existed in the input file” as relevant.