Working with Arrays of Objects (Due 23 Apr 2004)

You are helping a friend, who is a real estate agent, maintain a list of houses that are for sale in the Austin area. You have to define a class called House that has the following attributes and methods. The plus (+) sign indicates public and the (-) sign indicates private.
House
+address: Address
+area: int            // area in square feet
+bedRooms: int        // number of bedrooms
+bathRooms: int       // number of bathrooms
+garage: int          // number of cars in garage
+price: double        // list (asking) price in dollars

+House()              // default constructor
+House ( address: Address, area: int, bedRooms: int, bathRooms: int,
	 garage: int, price: double )
+toString(): String   // string representation of a house object
+priceSqft(): double  // price per square feet

You need a helper class called Address to represent the address of the houses. This class has the following structure:

Address
+street: String      // house number and street name
+town: String        // name of town or city
+state: String       // two letter abbreviation of state
+zip: String         // five digit zip code

+Address()           // default constructor
+Address ( street: String, town: String, state: String, zip: String )
+toString(): String  // string representation of address

You will need a class that maintains a list of houses. It also has methods to search for houses according to some criteria: by zip code, by price range, by range in square feet, and by the number of bedrooms. The structure for this class HouseList is as follows:

HouseList
-houseList: House[]    // array of houses
-numHouses: int	       // number of houses on the list

+HouseList()           // default constructor
+HouseList( n: int )   // creates an array of houses of size n
+getNumHouses (): int  // get the number of houses on the list
+addHouse ( house: House ): void     // adds a house to the list if 
				     // it is not full
+searchByZip ( zip: String): void    // prints the houses in that zip code
+searchByPrice ( lowPrice: double, highPrice: double ): void 
				     // prints the houses in the price range
+searchByArea ( lowArea: int, highArea: int ): void
				     // prints the houses in that square feet
				     // range
+searchByRooms ( rooms: int ): void  // prints the houses having that many
				     // bedrooms

Your main program will be called Realtor. You will be testing out the methods that you wrote for the classes Address, House, and HouseList. The structure for that class will be:

public class Realtor
{
  public static void main ( String[] args )
  {
    // Create a HouseList object that can hold a hundred houses
    ...

    // Populate the array with 10 houses. Makeup the data for these houses
    ...

    // Write out the number of houses in your list
    ...

    // Write out the houses in a certain zip code
    ...

    // Write out the houses in a certain price range
    ...

    // Write out the houses in a certain square foot range
    ...

    // Write out the houses that have a certain number of bedrooms
    ...

  }
}

The file that you will be turning in will be called Realtor.java. You will follow the standard Java coding convention that I have appended below. The file will have a header of the following form:

/*
  File: Realtor.java

  Description:

  Student Name:

  Student UT EID:

  Course Name: CS 303E

  Unique Number: 

  TA:

  Date Created:

  Date Last Modified:

*/

You will follow the standard Java Coding Conventions. You can either view the HTML page or download the PDF or Postscript and print it out. There is a modification that I would like to make to the standard coding conventions. Please align the opening and closing braces vertically so that you can easily make out the blocks of code.

Use the turnin program to submit your Realtor.java file. The TAs should receive your work by 5 PM, Friday, 23 April 2004.