|
Bill Teter email: william.teter@plattsburgh.edu |
|
|
Lab 1 Objectives: 1. Create a directory for this course, csc223: 2a. Go into this directory (ie. make it your pwd--present working
directory): 2b. Create a subdirectory of csc223 called weiss and make it your
present working directory: 3. Download code.tar from Mark Weiss' text site at Steps for lab project 1 4. Go back to directory csc223 and make a new subdirectory inside csc223 called lab1. 5. Make lab1 your present working directory. Use emacs to create two classes -- Person.java and House.java according to the following specifications: Person class Person will have the following fields: Person class will have the following constructor and
methods: House class House will have the following fields: House will have the following methods: Write a test program that tests the constructors and all the methods in both classes. Put the test program in its own class called Test.java. Make up data about a family or two and the houses they live in. It is impossible for all persons to have a mother and father without some incestuous relationships. So use null as the value for the mother and father fields when constructing persons when necessary. You may discover a problem as you print data about a person. The printing may go on forever. This is because House and Person reference each other. That is, a person may live in a house that he owns. To break the infinite recursion you might want to just print the name of the owner of the house rather than all the data about the owner. Likewise, in the Person class you may wish to only print the mother and father's names, not the entire state of the mother and father. To accomplish this you will need an accessor method for the name field in the Person class. Remember also that a method may not be invoked on a null object. |