Question
address_data 1a|777|56th avenue|v7n2m8|surrey |123|main street|v7r2g2|west vancouver |456|elm street|90210|los angeles 44|1111|maple street|v8y3r5|vancouver 9|99|gretzky way|t6v7h3|toronto b|711|country road|v8h5f5|maple ridge |8785|pinnacle avenue|v9u3h3|north vancouver |800|elm street|90557|los angeles |1515|main street|v8y7r3|west vancouver
address_data
1a|777|56th avenue|v7n2m8|surrey |123|main street|v7r2g2|west vancouver |456|elm street|90210|los angeles 44|1111|maple street|v8y3r5|vancouver 9|99|gretzky way|t6v7h3|toronto b|711|country road|v8h5f5|maple ridge |8785|pinnacle avenue|v9u3h3|north vancouver |800|elm street|90557|los angeles |1515|main street|v8y7r3|west vancouver 6|60|60th street|v8u9b1|burnaby 7h|1500|railway avenue|v9v5v4|richmond |333|elm street|90111|los angele
property_data
499000.0|2|false|residence|abc123|true 5999999.0|5|true|residence|xyz789|false 2500000.0|6|true|residence|777def|false 1000000.0|retail|876tru|1200|true 99999.0|commercial|9999|false|false 740100.0|3|false|residence|mr6789|false 15000000.00|20|true|residence|78444a|false 7100000.0|10|false|residence|mmm33|false 4000000.0|commercial|678T|true|true 700000.0|retail|y6yyy|750|false 840000.0|commercial|A1212|false|true 1600000.0|3|false|residence|9000a|false
In Assignment 2 we are building on top of what we created in the first assignment. This time around we will focus on design by incorporating Inheritance, reading data files, and on providing an interface so users can interact with the program at runtime. Changes and additions below are noted in blue font.
Class | Instance Variables | Methods |
Address | Unit number (String: must be one to four characters)
Street number (int must be 0 to 999999)
Street name (String: must be one to twenty characters)
Postal code (String: must be either length 5 or length 6)
City (String: must be one to thirty characters) | Get methods for all instance variables
toString() to display the state of Address objects |
|
|
|
Property | Price in USD (double, must be positive)
Address (Address, not null)
Type (String: must be one of: residence, commercial, or retail)
Property ID (String: must be one to six characters)
| Property will become a supertype that will hold common fields and behaviours of the subtype
Property will no longer support public int getNumberOfBedrooms() nor public boolean hasSwimmingPool() nor the associated fields
Get methods for all instance variables
Set method for price
toString() to display the state of Property objects
|
Residence extends Property | numberOfBedrooms(int: must not be less than 1)
swimmingPool (boolean: indicates presence of a pool)
strata (boolean: indicates if part of a strata) | Subtype of Property
Get methods for all fields
toString() for displaying the state of Residence types |
Commercial extends Property | loadingDock (boolean: indicates if it has a loading dock)
highwayAccess (boolean: indicates if easy access to a highway) | Subtype of Property
Get methods for all fields
toString() for displaying the state of Commercial types |
Retail extends Property | squareFootage (int: the amount of floor space available)
customerParking (boolean: indicates if customer parking is available) | Subtype of Property
Get methods for all fields
toString() for displaying the state of Retail types |
AddressReader |
| public static ArrayList readAddressData(File file) throws FileNotFoundException: reads address_data.txt (provided) and adds Address objects to an ArrayList and returns it. |
PropertyReader |
| public static ArrayList |
Agency | Name (String, 1 to 30 characters)
Properties (HashMap of properties; key is property id, value is a Property) | addProperty(property): adds the (non-null) property to the HashMap
removePropery(propertyId): removes the property whose ID matches the parameter, from the HashMap
getProperty(propertyId): returns the property whose ID matches the parameter, from the HashMap (or null if there is no match) getTotalPropertyValues(): returns the total amount in USD of all Properties
getPropertiesWithPools(): This method needs to be modified to return an ArrayList
getPropertiesBetween(minUsd, maxUsd): returns an array of properties whose price falls in the range specified by the parametersor null if there are none
getPropertiesOn(streetName): returns an ArrayList of addresses which are on the specified streetor null if there are none
getPropertiesWithBedrooms(minBedrooms, maxBedrooms): returns a HashMap of Residences (key is property id, value is the Residence) whose number of bedrooms falls in the range specified by the parametersor null if there are none. NOTE only Residence type have bedrooms so you will have to modify this method to look at Residence types only.
getPropertiesOfType(propertyType): this existing method needs to be modified to return an ArrayList
getPropertiesWithLoadingDock(): returns an ArrayList
getPropertiesWithHighwayAccess():returns an ArrayList
getProperties WithSquareFootage(int squareFootage): returns an ArrayList
getPropertiesWithCustomerParking():returns an ArrayList
getPropertiesWithStrata(): returns ArrayList
|
Assignment2 (driver class) | Agency: reference to the Agency class | public void init() throws FileNotFoundException: This method gets the ArrayList and ArrayList
public void doSearches(): This method provides the primary user interface through command prompts that will allow the user to choose which search operations to perform. See the Sample Interface below. Each search will display results to the console.
public static void main(String[] args) throws FileNotFoundException: Will create an instance of Assignment2 and use that to call init() and then doSearches().
|
Sample Interface. |
| Welcome to our Property search. Choose one of the following options:
------------------------------------------------------------------ General Queries
------------------------------------------------------------------ Residence Queries
------------------------------------------------------------------
Commercial Queries
------------------------------------------------------------------ Retail Queries
|
Sample Program Run |
| See video provided. |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started