Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Create the following classes along with the specified instance data and methods. Make sure you use /** Javadoc comments */ to comment all public

Java

Create the following classes along with the specified instance data and methods. Make sure you use /** Javadoc comments */ to comment all public classes, constructors, and methods (with the @author, @version, @return, and @param tags as appropriate). Make sure the constructor validates data as specified. All constructors and mutators must throw an IllegalArgumentException when parameters do not match the expected format (listed below). The main method must try/catch/finally every object creation. Make all data (including parameters) final if it is not expected/desired to change. Avoid magic numbers; e.g. use public static final double PI = 3.14 instead of simply using 3.14).

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

Property

Price in USD (double, must be positive)

Address (Address, not null)

Number of bedrooms (int: must be 1 to 20)

Swimming pool (boolean)

Type (String: must be one of: residence, commercial, or retail)

Property ID (String: must be one to six characters)

Get methods for all instance variables

Set method for price

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(): returns an ArrayList of such Propertiesor null if there are none

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 properties (key is property id, value is the Property) whose number of bedrooms falls in the range specified by the parametersor null if there are none

getPropertiesOfType(propertyType): returns a String, with all of the information about every property (one property per line) that is of the specified type (e.g. commErciAl: be case insensitive) in the exact format of:

Type: COMMERCIAL

1) Property 9999: unit #9 at 99Gretzky WayT6V7H3 in Toronto (1 bedroom): $99999.

2) Property 678T: 1515 Main Street V8Y7R3 in West Vancouver (2 bedrooms plus pool): $4000000.

3) Property A1212: unit #7h at 1500 Railway Avenue V9V5V4 in Richmond (4 bedrooms): $840000.

Note that the sample output above is exactly what should be returned for the data shown below; it must create similar sentence structures for any property of any type. Notice the capitalization of various parts of the string (see above) versus how it was stored (see below). Note that the order of the properties may differ from that above since a HashMap doesnt store in order, but the contents must otherwise match those above.

If there are NO properties of the specified type the output must be as follows:

Type: RETAIL

Sample run.

The unit tests create an agency named BCIT Ltd with the following properties:

unit

st #

st name

city

postal

# bed

type

id

$

1a

777

56th avenue

surrey

v7n2m8

2

res

abc123

499000

123

main street

west vancouver

v7r2g2

5

res

pool

xyz789

5999999

456

elm street

los angeles

90210

6

res

pool

777def

2500000

44

1111

maple street

vancouver

v8y3r5

1

ret

876tru

1000000

9

99

gretzky way

toronto

t6v7h3

1

com

9999

99999

b

711

country road

maple ridge

v8h5f5

3

res

mr6789

740100

8785

pinnacle avenue

north vancouver

v9u3h3

20

res

pool

78444a

15000000

800

elm street

los angeles

90557

10

res

mmm33

7100000

1515

main street

west vancouver

V8Y7R3

2

com

pool

678T

4000000

6

60

60th street

burnaby

v8u9b1

2

ret

pool

y6yyy

700000

7h

1500

railway avenue

richmond

v9v5v4

4

com

A1212

840000

333

elm street

los angeles

90111

3

res

9000a

1600000

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_2

Step: 3

blur-text-image_3

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 Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions