Question
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:
|
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