Hi There!

I'm Dan Schlegel, an Assistant 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. You will need to add an array of Items to the Room class and a way to add additional Items as you read them from the XML file.

Think carefully about linking the Room 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; all Rooms will have at most five characters in them; 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, neighbors, Characters and Items contained – with name and description for each Character and Item, Items should also note if they are broken) or output “no such room existed in the input file” as relevant.