Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the code for the assignment below and upload the zipped src folder to the learning hub (learn.bcit.ca Activities Assignments Assignment 2) before the

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Write the code for the assignment below and upload the zipped src folder to the learning hub (learn.bcit.ca Activities Assignments Assignment 2) before the dropbox due date. Include your full name at the top of each file, using a Java Javadoc /** @author */ tag (for example: /** @author Jason Harrison */). 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 Address Property Instance Variables 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) Price in USD (double, must be positive) Address (Address, not null) Type (String: must be one of: "residence", "commercial", or "retail") Get methods for all instance variables Methods toString() to display the state of Address objects 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 hasSwimming Pool() nor the associated fields Get methods for all instance variables Set method for price toString() to display the state of Property objects 1 Class Residence extends Property Commercial extends Property Retail extends Property AddressReader Property Reader Agency Instance Variables Property ID (String: must be one to six characters) numberOfBedrooms(int: must not be less than 1) swimming Pool (boolean: indicates presence of a pool) strata (boolean: indicates if part of a strata) loadingDock (boolean: indicates if it has a loading dock) highway Access (boolean: indicates if easy access to a highway) squareFootage (int: the amount of floor space available) customerParking (boolean: indicates if customer parking is available) Name (String, 1 to 30 characters) Properties (HashMap of properties; key is property id, value is a Property) Subtype of Property Get methods for all fields toString() for displaying the state of Residence types Subtype of Property Get methods for all fields toString() for displaying the state of Commercial types Subtype of Property Get methods for all fields Methods toString() for displaying the state of Retail types public static ArrayList readAddressData(File file) throws FileNotFoundException: reads "address_data.txt" (provided) and adds Address objects to an ArrayList and returns it. public static ArrayList readPropertyData(File file) throws FileNotFoundException: reads "property_data.txt" (provided) and adds Strings (for each line) to an ArrayList and returns it. addProperty(property): adds the (non-null) property to the HashMap removePropery(propertyld): removes the property whose ID matches the parameter, from the HashMap getProperty(propertyld): returns the property whose ID matches the parameter, from the HashMap (or null if there is no match) Class Assignment2 (driver class) Instance Variables Agency: reference to the Agency class Methods get Total PropertyValues(): returns the total amount in USD of all Properties getPropertiesWithPools(): This method needs to be modified to return an ArrayList type properties since only that type will now have swimming pools getPropertiesBetween(minUsd, maxUsd): returns an array of properties whose price falls in the range specified by the parameters...or null if there are none get PropertiesOn(streetName): returns an ArrayList of addresses which are on the specified street...or null if there are none get Properties With Bedrooms(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 parameters...or 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(property Type): this existing method needs to be modified to return an ArrayList that hold the subtype specified in the parameter. getPropertiesWithLoading Dock(): returns an ArrayList that holds only Commercial properties that have a loading dock available get PropertiesWithHighwayAccess():returns an ArrayList that holds only Commercial properties that have highway access getProperties WithSquareFootage(int squareFootage): returns an ArrayList that holds properties where square footage is at least the parameter value. getProperties With CustomerParking():returns an ArrayList that holds properties where customer parking is available. getProperties WithStrata(): returns ArrayList that hold only the Residences that are in a strata. public void init() throws FileNotFoundException: This method gets the ArrayList and ArrayList form AddressReader and PropertyReader, and uses them to create subtype Objects 3 Class Sample Interface. Instance Variables Methods and adds them to the Agency.HashMap properties 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(). Welcome to our Property search. Choose one of the following options: 1. 2. 3. 4. 5. General Queries - will present the General Queries menu Residence Queries - will present the Residence Queries menu Commercial Queries - will present the Commercial Queries menu Retail Queries - will present the Retail Queries menu Exit - will exit the program General Queries 1. By Property ID - will further prompt to ender Property ID, then call Agency.getProperty (propertyld) and display the result to the console 2. By Price - will further prompt to enter both min and max ranges, call Agency.getProperties Between(minUsd, maxUsd) and display results to the console 3. By Street-will further prompt to enter the Street name, call Agency.getProperties On (streetName) and display results to the console 4. By Type - will further prompt to enter the property type (residence, commercial, retail), call Agency.getProperties OfType(property Type) and display results to the console 5. Back-will take you back to the main menu Residence Queries 1. By Bedroom - will further prompt to enter the min and max ranges, call Agency.getPropertiesWith Bedrooms(minBedrooms, maxBedrooms) 2. By Pool - will call Agency.getProperties With Pools() and display only the residences that have swimming pools 3. By Strata - will call Agency.getPropertiesWithStrata() and display the results to the console 4. Back - will take you back to the main menu Class Sample Program Run Instance Variables Commercial Queries 1. By Loading Dock - will call Agency.getPropertiesWithLoading Dock() and display results to the console Methods 2. By Highway Access - will call Agency.getProperties With HighwayAccess() and display the results to the console 3. Back-will take you back to the main menu Retail Queries 1. By Square Footage - will further prompt for min square footage value, call Agency.getProperties WithSquare Footage(int square Footage) and display results to the console 2. By Customer Parking - will call Agency.getProperties With CustomerParking() and display only Retail properties where customer parking is available 3. Back-will take you back to the main menu See video provided. L O

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Based on the instructions and specifications given in the images your task is to implement a Java program with classes that model a real estate agency You have been provided with a class hierarchy and ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

Explain the experimental method as used by clinical psychologists.

Answered: 1 week ago