COSC 2P05 – Programming Languages Assignment #2
Due Date: Wednesday February 21, 12:00 noon Late date: Saturday, February 24, 12:00 noon This assignment accounts for 10% of your final grade and is worth a total of 10 marks.
Niagara Real Estate Company
The Niagara Real Estate Company maintains a list of properties for sale. Properties come in four types:
1. commercial retail
2. commercial industrial 3. residential
4. farm
All properties, regardless of their type, have the following five attributes:
1. annual property taxes
2. list price
3. lot size (in square feet)
4. location (the city)
5. building (the building on the property)
For convenience Niagara Real Estate has divided the Niagara Peninsula into four cities. These are the only valid locations:
1. stct (St. Catharines) 2. wlld (Welland)
3. ngfl (Niagara Falls) 4. fter (Fort Erie)
All smaller cites and towns are grouped with the nearest large city.
Commercial retail properties have one additional attribute, the retail type. This will be either:
1. strip mall 2. large mall 3. street
Commercial industrial properties have one additional attribute, the industry type. This will be either:
1. light 2. medium 3. heavy
Residential properties have four additional attributes:
1. sewer (is the property on city sewers y/n) 2. water (is the property on city water y/n)
3. garage (does the property have a garage y/n) 4. pool (does the property have a pool y/n)
The farm property type is treated as a residential property with one additional attribute, the crop type. These are the only valid crop types:
1. cash
2. vineyard 3. fruit
4. poultry
This is all the information you should need on properties. A description of buildings follows. Buildings come in three types:
1. store 2. factory 3. house
Obviously, stores go on commercial retail properties, factories go on commercial industrial properties, and houses go on residential and farm properties.
All buildings, regardless of their type, have the following two attributes:
1. construction material 2. size (in square feet)
Construction materials come in four types:
1. brick 2. wood 3. siding 4. other
Store building types have three additional attributes:
1. shelves (is the shelving included in the sale y/n)
2. checkout (are the cash registers included in the sale y/n) 3. safe (is a safe included in the sale y/n)
Factory building types have three additional attributes:
1. crane (is an overhead crane included y/n) 2. equipment (is other equipment included y/n) 3. rail access (is there railway access y/n)
House building types have 4 additional attributes:
1. number of bedrooms
2. number of bathrooms
3. basement (is there a basement y/n) 4. house type
House types come in the following types:
1. condo
2. row
3. semi
4. bungalow 5. split
6. two story
The problem
The Niagara Real Estate Company has hired you to create a program that will search the list of the properties for sale, based on certain parameters, then display the information on those properties that match the parameters. The search parameters will be the city (stct, wlld, fter, ngfl), the property type (commretail, commindust, residential, farm) and the asking price. For example, the following search should return all of the residential properties in St. Catharines with a list price of $500000 or less.
It is very important that you use exactly the abbreviations listed above for your search parameters. This is to simplify marking. The marker should not have to dig through your code to figure out what string you have used. If your search does not run on the parameters given above your program may be marked as inoperative. Note, to remove any ambiguity you could use radio buttons for the city and the property type, but this is not required.
After you enter the search parameters and click the search button, the program should return a list of properties that match the search criteria and display the first one.
Clicking the next button will display the next property that matches the search criteria:
If there are no more properties to display then clicking the next button should display a message indicating this:
If you search for a different type of property, the result displayer will show different attributes. Here we searched for commindust in wlld costing 5000000 or less. You should not use the same result displayer for all property types. The displayer should match the property type it displays.
Even though a farm is regarded as a type of residential, it should not appear in a search for residential properties. A farm should only appear in a search for a farm property.
Input File Format
The list of properties is stored in a tab delimited text file. This is available with the assignment on Sakai. The following describes the format of the input file. This is a description of one line reading from the left. Note: I have tested this data with many different searches and it seems to work OK. However, I have not tried all possible combinations of location, property type and price, so it is possible there is a bad line of data in the file. If you think you have found bad data, please report this to me.
char buildingType s (store), f (factory), h (house) if buidlingType is s
int sqft String Material
(building size in square feet) (building material given by brick, wood, siding,
other) (is shelving included in the sale y/n)
boolean shelves boolean checkout (is the checkout equipment included y/n) boolean safe (is a safe included y/n)
if buildingType is f int sqft (building size in square feet)
String Material (building material given by brick, wood, siding, other)
boolean crane (is an overhead crane included y/n) boolean equipment (is other equipment included y/n) boolean railAccess(does the factory have rail access y/n)
if building type is h
int sqft (building size in square feet) String Material (building material given by brick, wood, siding,
other) String houseType (type of house given by condo, row, semi, bungalow,
split, twostory) (the number of bedrooms) (the number of bathrooms) (does the house have a basement y/n)
r (residential), i (industrial), s (store retail), f (farm)
(annual property tax) (the list price) (the lot size in square feet) (the municipality given by stct, wlld, ngfl, fter) (is the property on city sewers y/n) (is the property on city water y/n) (does the property have a garage y/n) (does the property have a pool y/n)
(annual property tax) (the list price) (the lot size in square feet) (the municipality given by stct, wlld, nglf, fter) (light, medium, heavy)
int tax int price int lotSize String Location n (the municipality given by stct, wlld, nglf, fter) String RetailType (stripmall, largemall, street)
int bedrooms int bathrooms boolean bsmt
char propType
if propType is r
int tax int price int lotSize String Location boolean sewer boolean water boolean garage boolean pool
if propType is i
int tax int price int lotSize String Location IndustryType
if propType is s
(annual property tax) (the list price) (the lot size in square feet)
if propType is f
int tax int price int lotSize String Location boolean sewer boolean water boolean garage boolean pool String CropType
(annual property tax) (the list price) (the lot size in square feet) (the municipality given by stct, wlld, nglf, fter) (is the property on city sewers y/n) (is the property on city water y/n) (does the property have a garage y/n) (does the property have a pool y/n) (cash, vineyard, fruit, poultry)
Programming Instructions and Hints
The purpose of this assignment is to give students practice with inheritance and polymorphism. If your program does not use these tools, then you will get a poor mark. This assignment involves significantly more coding than Assignment 1. I recommend that you get started as soon as possible.
Begin by reading the problem until you understand it. Next, draw up inheritance diagrams. Decide what variables and methods each class will have. Write the code for these classes. Then write the code to read the input file and create the objects. Store them in some data structure. (There is no restriction on using library container classes in this assignment.)
Next, write the code for the search parameter GUI and the result displayer(s) GUI. I suggest you use BasicIO for this. If you have a good understanding of Swing and AWT then feel free to use these libraries, but there are no extra marks for this. Your GUI does not have to be elegant or beautiful. It just has to work.
My code used enums for things like house type, crop type, building material, retail type and so on. This caused considerable extra work, because I had to convert from string to enum when reading the input file then from enum to string when I was displaying the results. I think it would be easier to keep these variables as strings from start to finish.
I am not requiring any error checking on inputs, either in the input file, or in the search parameter GUI. There are simply too many different possible errors to catch and handle.
You must submit an inheritance diagram (tree drawing) with your program. It should show your classes and the variables in each one. This can be done in with a drawing program, or it can be done by hand then scanned. If it is done by hand it must be neat and legible. If the marker can’t read it, he can’t mark it.
Programs must be written in Java. You can use any IDE that is available on the Brock Lab computers. Your program must run and compile on the lab computers or it will not be marked. You should provide a statement specifying the IDE used as well as any additional information needed to run your program.
Submission Requirements
All assignments must be completed individually. Programs may be checked for plagiarism using MOSS.
No paper submission is required for this assignment. All assignments are to be submitted through Sakai. You should have a folder for the assignment (Assign_2). This folder should include what is needed for the marker to run and compile your program. Zip this folder as Assign_2.zip. Log on to Sakai and select the COSC 2P05 site. On the Assignments page select Assignment 2. Attach your .zip file (e.g. Assign_2.zip) to the assignment submission (use the Add Attachments button and select Browse. Navigate to where you stored your assignment and select the .zip file (e.g. Assign_2.zip). The file will be added to your submission. Be sure to read and check the Honour Pledge check box. Press Submit to submit the assignment. You should receive a confirmation email.
Note: The due date will be set in Sakai to Wednesday, February 21 at 12 noon. The accept until date is set to Saturday, February 24 at 12 noon to allow any late assignments to be submitted. I realize this is during the break, but since I am not requiring a paper submission this should not be an issue. Late assignments will be penalized 25%. Sakai is currently configured to allow one re-submission up to the late date. Be sure your program is correct before you submit it.
Mark Allocation: 3 marks for a working search regardless of your class structure. 1 mark for proper commenting, naming conventions, indentation etc. 1 mark for the class drawing. 5 marks for a proper implementation of the class hierarchies. (These marks may be contingent on your search working.)