Question: I'm working on the following Java project and have run into a bit of a roadblock. I have the following Classes and corresponding instance variables:

I'm working on the following Java project and have run into a bit of a roadblock.

I have the following Classes and corresponding instance variables:

Class Address - unitNumber (must be a string between 1 and 4 characters) - streetNumber (must be an integer between 0 and 999999 characters) - streetName (must be a string between 1 and 20 characters) - postalCode (must be a string and either length 5 or length 6) - city (must be a string between 1 and 30 characters) Class Property - priceInUSD (must be a double and can't be a negative value) - address (from Class Address) - numberOfBedrooms (must be an integer between 1 and 20) - swimmingPool (boolean) - type (must be a string and has to be "residence", "commercial" or "retail") - propertyID (must be a string between 1 to 6 characters)

Class Agency - name (must be a string between 1 to 30 characters) - properties (must be a HashMap of properties; key is propertyID and value is a Property)

the Class Agency also has the following methods:

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 99 Gretzky Way T6V7H3 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

I'm currently stuck on the getPropertiesWithPool() ... I have been able to iterate through my HashMap correctly using the code below, but can't figure out how to add them to an arraylist properly.

ArrayList listOfSwimmingPools = new ArrayList(); for(Map.Entry property : properties.entrySet()){ if(property.getValue().isSwimmingPool() == true) { Property prop = new Property(priceInUSD, address, numberOfBedrooms, swimmingPool, type, propertyID); listOfSwimmingPools.add(prop);

Any help would be greatly appreciative. If you feel the urge to complete the rest of the project - I will try and complete them myself first and use your answers as guidelines if I become stuck again.

Thanks in advance.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!