In this assignment, we will write an application that will help Reality Realty, Inc. print listings for the homes it is selling.
The program starts by asking the Reality Realty agent for the name of the file that contains their database of homes. The file is tab-delimited and list information about multiple properties. Each home begins with a line that lists the home's id number, address, city, state, zip, number of bedrooms, number of bathrooms, price, and description. The next lines, each of which are indented by one tab, specify the names and dimensions of the rooms, with the name, width, and length of each room separated by tabs. The next home in the file begins at the next line that does not begin with a tab. The file is included in the homework folder and is called homes.txt. Here is what it looks like: see image.
Once the agent enters the name of the file, the program will read it and then produce a nicely formatted report that looks exactly like what is shown on the next page. It will present the properties sorted by their MLS number.
A major emphasis of this assignment is how you structure it because the intent of this work is to give you practice working with inheritance and composition. A Home is a kind of Property, so you have to define a Property class first that contains all the characteristics that all properties have, and then add on the Home-specific properties in the Home class. In other words, Home is a subclass of Property. A Home has rooms in it, so the Home class should have a list of Room objects in it. That demonstrates a composition relationship in which Home is the owner class and the ArrayList of Room objects is the owned object. It is important that you include these classes and relationships in your code.
The characteristics you need to store for a Home are the id number, description, address, city, state, zip code, number of bedrooms, number of bathrooms, price, and the array list of rooms. Some of these features and their corresponding getters and setters should be inherited from Property, and some are native to Home since Home is a more specific kind of Property.
These, then, are the class you must define:
Property: contains the characteristics that can be used to describe all kinds of properties, including open land and storefronts. Include all the usual bells and whistles: constructors, getters, setters, toString, and any other functions you think are useful.
Home: extends Property, but adds Home-specific characteristics, including an ArrayList of Room object. Include constructors, getters, setters, a toString, a function for finding the overall square footage of the home, and any other things you think a Home needs.
Room: contains the name, length, and width of a room. It has constructors, get and set functions, a toString() function, and a getArea() function that determines the area of the room.
HomeReader: a library-style class that contains a static function called readHomesFromFile that takes in the name of the file to read (i.e. the name of the file that contains the data about the homes Reality Realty is selling) and returns an ArrayList of Home objects. If the named file does not exist, the function should return null.
HomeLister: a library-style class that contains a static function called listHomes that takes in the ArrayList of Home objects and prints the nicely formatted report you see below.
RealityRealty: the main class whose main function asks the user for the name of the file, asks HomeReader to read it to build the ArrayList of Home objects, and then asks HomeLister to generate the report.
This is the output your program should produce. The report should look exactly as shown. see image.