CSC241: Homework 3


In this homework 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 Homework 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.

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 ten creatures in them; etc.

You should write a Main class, containing a main method. 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, state, neighbors, and Creatures contained - with name, type and description for each Creature) or output "no such room existed in the input file" as relevant.