Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a class called Address. The class should declare the following variables: - an instance variable that describes the country - String - an instance

Make a class called Address. The class should declare the following variables: - an instance variable that describes the country - String - an instance variable that describes the province - String - an instance variable that describes the city - String - an instance variable that describes the street name - String - an instance variable that describes the street number - integer - an instance variable that describes the unit number - integer - an instance variable that describes the postal code - String

Make an abstract class called Property. The class should declare the following variables: - an instance variable that describes the bedrooms - Integer - an instance variable that describes the bathrooms - Integer - an instance variable that describes the if the property has parking - Boolean - an instance variable that describes the living area - integer - an instance variable that describes the price - integer - a member that describes the address - Address (composition)

Make an abstract method for Property class called displayInfo() that returns a String.

Make the getter and setter methods for each instance variable and necessary constructors. Provide a toString() method that returns the information stored in the above variables.

Create three subclasses called House, Condo, and TownHouse.

Make an Interface called Insurable with following method: - setPremium(price Integer) that takes the price as input and returns a double

These subclasses should implement Insurable Interface. You need to use the following rules to implement the interface methods:

o For houses, premium equals house price multiply 0.002 o For town houses, premium equals town house price multiply 0.0015 o For condos, premium equals condo price multiply 0.001

These subclasses should implement displayInfo() method. This method should return a String including type of property, price of the property, and premium.

Write a driver program (another class with main method) that uses the above hierarchy. In your driver program you should implement an interaction flow with the user. You must use JOptionPane to interact with the user.

Use showInputDialog method to let the user enter how many property objects should be created in the current session. Each class has its own setPremium method. Your polymorphic screen manager should walk the user through the array using showInputDialog. After selecting the property type and entering the price, an appropriate object (condo/house/townhouse) should be instantiated and the premium should be calculated accordingly by sending setPremium messages to each object in the array. Use the displayInfo() and showMessageDialog to display information of all properties in the array including property type, price, and premium.

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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions