Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

image text in transcribed

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 readPropertyData(File file) throws FileNotFoundException: reads property_data.txt (provided) and adds Strings (for each line) to an ArrayList and returns it.

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 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 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 that hold the subtype specified in the parameter.

getPropertiesWithLoadingDock(): returns an ArrayList that holds only Commercial properties that have a loading dock available

getPropertiesWithHighwayAccess():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.

getPropertiesWithCustomerParking():returns an ArrayList that holds properties where customer parking is available.

getPropertiesWithStrata(): returns ArrayList that hold only the Residences that are in a strata.

Assignment2

(driver class)

Agency: reference to the Agency class

public void init() throws FileNotFoundException: This method gets the ArrayList

and ArrayList form AddressReader and PropertyReader, and uses them to create subtype Objects 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().

Sample Interface.

Welcome to our Property search.

Choose one of the following options:

  1. General Queries will present the General Queries menu
  2. Residence Queries will present the Residence Queries menu
  3. Commercial Queries will present the Commercial Queries menu
  4. Retail Queries will present the Retail Queries menu
  5. Exit will exit the program

------------------------------------------------------------------

General Queries

  1. By Property ID will further prompt to ender Property ID, then call Agency.getProperty(propertyId) and display the result to the console
  2. By Price will further prompt to enter both min and max ranges, call Agency.getPropertiesBetween(minUsd, maxUsd) and display results to the console
  3. By Street will further prompt to enter the Street name, call Agency.getPropertiesOn(streetName) and display results to the console
  4. By Type will further prompt to enter the property type (residence, commercial, retail), call Agency.getPropertiesOfType(propertyType) 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.getPropertiesWithBedrooms(minBedrooms, maxBedrooms)
  2. By Pool will call Agency.getPropertiesWithPools() 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

------------------------------------------------------------------

Commercial Queries

  1. By Loading Dock will call Agency.getPropertiesWithLoadingDock() and display results to the console
  2. By Highway Access will call Agency.getPropertiesWithHighwayAccess() 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 WithSquareFootage(int squareFootage) and display results to the console

  1. By Customer Parking will call Agency.getPropertiesWithCustomerParking() and display only Retail properties where customer parking is available
  2. Back will take you back to the main menu

Sample Program Run

See video provided.

AutoSave CM HUB 2501_Assignment2_edit2 - Compatibility Mode - Word o search Ashu thakur File Home Insert Draw Design Layout References Mailings Review View Help Table Design Layout Share Comments Find 21 ceD: :. . Paste Copy X cut In Fomat Painter Clipboard Calibri (Excly) - 11 A A A A BIV XX A.0.A. 1 Normal No Spec... Heading 1 Heading 2 Title Subtitle Subtle Em... = Replace > Select Dictata Sensitivity Editor Font Paragraph Styles Editing Voice Sensitivity Editor In this 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 Get methods for all instanca variables one to four characters toStil to display the state of Address objects Street number(int must be to 999999) Street name (Strings must be one lo lwenty characters) Postal code (String must be either length 5 or length 6) City (String: must he one to thirty characters) Properly Price in USD (double, must be positive) Property will become a supertype that will hold common fields and behavions of the subtye Property will no longer support public int ge Nurukis Older) non public bresao haswimming Poall) nor the associated fields Address Address, not null) Get methods for all instance variables Type String: must be one of: "residence","commercial, or "retail) Set method for prica toStato display the state of Property objects 1 ] COMP2501 Assignment 2 Due on dropbox date Methods Instance Variables Property ID (String: must be one to six characters Hesidence ., must Dar 25 1990 IT Day Selline Trans E AutoSave CM UB 2501_Assignment2_edit2 - Compatibility Mode - Word O Search Ashu thakur File Home Insert Draw Design Layout References Mailings Review View Help Table Design Layout Share Comments , . X cut Paste Format Painter Clipboard Calibriedy) 10 A A A A BIU*XX A-D-A- T ===== Find Replace Select 1 Normal No Spac... Heading 1 Heading Tite Subtitle Subtle Em.. Dictata Sensitivity Editor Font Paragraph Styles Editing Voice Sensitivity Editor COMP2501 Assignment 2 Due on dropbox date Class Methods Instance Variables Property ID Strings must be urie lo six characters Residence numberOfBedroomslint: must extends Property not be less than 1) Subtype of Property Get methods for all fields swimming Pool (balean: indicates presence of a pool toStained for displaying the state of Residence types strata hoolean: indlicates if part of a strata) Commercial loadingDock boolean extends Properly indicates if it has a loading dock) Subtype of property Gec methods for all fields 195LC) for displaying the state of Commercial types Retail extends Property highwayscess tuxelsan indicates it easy access to a highway) squarsFogtegelint: the amount of floor space available) Subtype of Property Get methods for all fields toString for displaying the state of Retail types customer Parking (baslean indicates il customer parking is available) AddressReader Egedes public static ArrayList
readAddressData(File file) throws FileNotFoundException: reads "address data.txt" [provided) and adds Address objects to an ArrayListAddress and returns it public static ArrayList and returns it. addProperty/property): adds the non-null) property to the HashMap Agency Name (String, 1 to 30 characters) Properties (HashMap of properties; key is property id. value is a Property removeProperylpropertyld): removes the property whose ID matches the parameter, from the Last Maga getProperty propertyld): returns the property whose ID matches the parameter, from the Hash Map for nullit there is no match) 2 } Dar 25 1990 IT Day Sellinen E 10 AutoSave CM UB 2501_Assignment2_edit2 - Compatibility Mode - Word O Search Ashu thakur File Home Insert Draw Design Layout References Mailings Review View Help Table Design Layout Share Comments SA ceDr AaBbct AABtice: . X cut Paste Format Painter Clipboard Calibriedy) 10 A A A A BIVX, X APA- Find Replace Select 1 Norma No Spec. Heading 1 Heading 2 Tite Subute Subtle Em... = Dictata Sensitivity Editor Font Paragraph Styles Editing Voice Sensitivity Editor Instance Variables Methods getTotalPropertyValues(); returns the total amount in USD of all Properties getProperties WithPools(): This method needs to be modified to retum an ArrayList form AddressReader and Property Reader, and uses them to create suhtync Objects Assignment2 (driver class) Agency: reference to the Agency class { 3 ] Danir 35 1990 IT LG TY - TH TT11111 10 AutoSave CM HUB 2501_Assignment2_edit2 - Compatibility Mode - Word o search Ashu thakur File Home Insert Draw Design Layout References Mailings Review View Share Comments 41 X cut In Fomat Painter Clipboard Raste Copy Calibri (key) - 11 A A A A BIU*XX A-D-A- Help Table Design Layout ceDr AaBbct AABtice: . 1 Normal 1 No Spec... Heading 1 Heading 2 Subtitle Subtle Em... = Find Replace > Select Tite Dictata Sensitivity Editor Font Paragraph Styles Editing Voice Sensitivity Editor Class Instance Variables Methods and adds them to the Agency, HashMapsString, Property> properties public void daSearches]): This method provides the primary user interface through command prompts that will allow the user to choose which search operations to peronin. See the Sample Interface below. Each search will display results to the console. public static void main(Strinell ares) throws FileNotFoundException: Will create an instance of Assignment and use that to call ici) and then seastus(). Sample Interface. Welcome to our Property Search Choose one of the following options: 1. General Queries - will present the General Queries menu 2. Residence Qucrics - will present the Residence Qucrics menu 3. Curninercial Queries will present the Commercial Queries menu lielail Queries - will preseril the lielail Queries reru 5. Fxit - will exit the program General Queries 1. By Property ID - will further prompt to ender Property ID, then call Acense.detenedlaegertxld) and display the result to the console 2. By Price will further prompt to enter both min and max ranges, call Agency.setPropertiesBetween minlisd, marlisd and display results to the console 3. By Street-will further prompt to enter the Street name, call AcensweetlepectiesDolstreetName) and display results to the console 1. By Type will further prompt to enter the property type (residence, commercial, retail), call Asus PROLIXIRI) and display results to the wo 5. Back - will take you back to the main menu Residence Queries 1. By Bedroom - will further prop. lo enter the mir ard max ranges, call Agency BetPrapertiesWithBedroomamin Bedrooms, maxBedrooms 2. By Paal - will call Ascng.ct Proactics With Pools) and display only the residences that have swimming pools 3. Ry Strata - will call Agency At PropertiesWith Strata() and display the results to the console 1. Back will take you back to the main menu { 4 ] Part 5 1990 IT rri Yulfattitle Dil Sellise 10 AutoSave CM HUB 2501_Assignment2_edit2 - Compatibility Mode - Word o search Ashu thakur File Home Insert Draw Design Layout References Mailings Review View Help Table Design Layout Share Comments Find 21 ceD: :. . Paste Copy X cut In Fomat Painter Clipboard Calibri (Excly) - 11 A A A A BIV XX A.0.A. 1 Normal No Spec... Heading 1 Heading 2 Title Subtitle Subtle Em... = Replace > Select Dictata Sensitivity Editor Font Paragraph Styles Editing Voice Sensitivity Editor In this 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 Get methods for all instanca variables one to four characters toStil to display the state of Address objects Street number(int must be to 999999) Street name (Strings must be one lo lwenty characters) Postal code (String must be either length 5 or length 6) City (String: must he one to thirty characters) Properly Price in USD (double, must be positive) Property will become a supertype that will hold common fields and behavions of the subtye Property will no longer support public int ge Nurukis Older) non public bresao haswimming Poall) nor the associated fields Address Address, not null) Get methods for all instance variables Type String: must be one of: "residence","commercial, or "retail) Set method for prica toStato display the state of Property objects 1 ] COMP2501 Assignment 2 Due on dropbox date Methods Instance Variables Property ID (String: must be one to six characters Hesidence ., must Dar 25 1990 IT Day Selline Trans E AutoSave CM UB 2501_Assignment2_edit2 - Compatibility Mode - Word O Search Ashu thakur File Home Insert Draw Design Layout References Mailings Review View Help Table Design Layout Share Comments , . X cut Paste Format Painter Clipboard Calibriedy) 10 A A A A BIU*XX A-D-A- T ===== Find Replace Select 1 Normal No Spac... Heading 1 Heading Tite Subtitle Subtle Em.. Dictata Sensitivity Editor Font Paragraph Styles Editing Voice Sensitivity Editor COMP2501 Assignment 2 Due on dropbox date Class Methods Instance Variables Property ID Strings must be urie lo six characters Residence numberOfBedroomslint: must extends Property not be less than 1) Subtype of Property Get methods for all fields swimming Pool (balean: indicates presence of a pool toStained for displaying the state of Residence types strata hoolean: indlicates if part of a strata) Commercial loadingDock boolean extends Properly indicates if it has a loading dock) Subtype of property Gec methods for all fields 195LC) for displaying the state of Commercial types Retail extends Property highwayscess tuxelsan indicates it easy access to a highway) squarsFogtegelint: the amount of floor space available) Subtype of Property Get methods for all fields toString for displaying the state of Retail types customer Parking (baslean indicates il customer parking is available) AddressReader Egedes public static ArrayList
readAddressData(File file) throws FileNotFoundException: reads "address data.txt" [provided) and adds Address objects to an ArrayListAddress and returns it public static ArrayList and returns it. addProperty/property): adds the non-null) property to the HashMap Agency Name (String, 1 to 30 characters) Properties (HashMap of properties; key is property id. value is a Property removeProperylpropertyld): removes the property whose ID matches the parameter, from the Last Maga getProperty propertyld): returns the property whose ID matches the parameter, from the Hash Map for nullit there is no match) 2 } Dar 25 1990 IT Day Sellinen E 10 AutoSave CM UB 2501_Assignment2_edit2 - Compatibility Mode - Word O Search Ashu thakur File Home Insert Draw Design Layout References Mailings Review View Help Table Design Layout Share Comments SA ceDr AaBbct AABtice: . X cut Paste Format Painter Clipboard Calibriedy) 10 A A A A BIVX, X APA- Find Replace Select 1 Norma No Spec. Heading 1 Heading 2 Tite Subute Subtle Em... = Dictata Sensitivity Editor Font Paragraph Styles Editing Voice Sensitivity Editor Instance Variables Methods getTotalPropertyValues(); returns the total amount in USD of all Properties getProperties WithPools(): This method needs to be modified to retum an ArrayList form AddressReader and Property Reader, and uses them to create suhtync Objects Assignment2 (driver class) Agency: reference to the Agency class { 3 ] Danir 35 1990 IT LG TY - TH TT11111 10 AutoSave CM HUB 2501_Assignment2_edit2 - Compatibility Mode - Word o search Ashu thakur File Home Insert Draw Design Layout References Mailings Review View Share Comments 41 X cut In Fomat Painter Clipboard Raste Copy Calibri (key) - 11 A A A A BIU*XX A-D-A- Help Table Design Layout ceDr AaBbct AABtice: . 1 Normal 1 No Spec... Heading 1 Heading 2 Subtitle Subtle Em... = Find Replace > Select Tite Dictata Sensitivity Editor Font Paragraph Styles Editing Voice Sensitivity Editor Class Instance Variables Methods and adds them to the Agency, HashMapsString, Property> properties public void daSearches]): This method provides the primary user interface through command prompts that will allow the user to choose which search operations to peronin. See the Sample Interface below. Each search will display results to the console. public static void main(Strinell ares) throws FileNotFoundException: Will create an instance of Assignment and use that to call ici) and then seastus(). Sample Interface. Welcome to our Property Search Choose one of the following options: 1. General Queries - will present the General Queries menu 2. Residence Qucrics - will present the Residence Qucrics menu 3. Curninercial Queries will present the Commercial Queries menu lielail Queries - will preseril the lielail Queries reru 5. Fxit - will exit the program General Queries 1. By Property ID - will further prompt to ender Property ID, then call Acense.detenedlaegertxld) and display the result to the console 2. By Price will further prompt to enter both min and max ranges, call Agency.setPropertiesBetween minlisd, marlisd and display results to the console 3. By Street-will further prompt to enter the Street name, call AcensweetlepectiesDolstreetName) and display results to the console 1. By Type will further prompt to enter the property type (residence, commercial, retail), call Asus PROLIXIRI) and display results to the wo 5. Back - will take you back to the main menu Residence Queries 1. By Bedroom - will further prop. lo enter the mir ard max ranges, call Agency BetPrapertiesWithBedroomamin Bedrooms, maxBedrooms 2. By Paal - will call Ascng.ct Proactics With Pools) and display only the residences that have swimming pools 3. Ry Strata - will call Agency At PropertiesWith Strata() and display the results to the console 1. Back will take you back to the main menu { 4 ] Part 5 1990 IT rri Yulfattitle Dil Sellise 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

13. You always should try to make a good first impression.

Answered: 1 week ago