Computer Science 212

Project 2 hints

Copyright © 2008 by Dorothy L. Nixon. All rights reserved.



Test programs (download as ZIP file here)

As discussed in class, it is recommended that you write class House first. It can be tested using the test programs below.

Below are data files to be used with the test programs:

The test programs may be downloaded in a ZIP file here.

In addition to the test programs and data files, project-2-hints.zip also contains a correctly-working House.class file so that you can see what the test programs will do with a correct version of class House.


Program development suggestions

As mentioned in the instructions, it is recommended that you write and test class House, to be defined in House.java, before you write any other part of your program.

It is further recommended that you write and test class House itself piecemeal, in the following order:

  1. Write the class heading and class curly braces. Then declare the instance variables, then write the get methods and a preliminary version of the constructor which just sets the values of the instance variables without bothering with the error checking (or exception-throwing) yet. (You can add the error-checking later.) Then write the toString method and any private methods you may need to write in order for the toString method to generate a string which always has the proper format. Then test what you've written so far using HouseTest1.java and HouseTest1A.java, with data files project2-data-good.txt and project2-data-bad.txt.
  2. Write the recommended private static methods and the public isValidHouse method, which will call the private methods. Test the public isValidHouse method (and the private methods that it calls, directly or indirectly) using HouseTest2.java with data files project2-data-good.txt and project2-data-bad.txt.
  3. Add error-checking (and exception-throwing) to the constructor, using calls to your private static methods. Test your constructor error-checking (and thereby also do some further testing of your private static methods) using HouseTest1.java, HouseTest1A.java, and HouseTest2.java.
  4. Write the equals method. Test it using HouseTest4.java. Test it with all five of the data files provided here.
  5. Write the compareTo method. Test it using HouseTest5.java. Test it with data files project2-data-good.txt and project2-data-bad.txt.

Then write your main class Project2 and GUI class (HouseGUI) without any calls to sorting methods. Make sure it displays unsorted lists of pets properly on the two text areas where, in your completed project, the two sorted lists will appear.

Then write class HouseSorting and call its public methods in HouseGUI.java, so that the two sorted lists are displayed.



Computer Science 212:  main page