Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA QUESTION: General Scenario: You are creating an interactive application that gets input from the keyboard and keeps track of the residences that a supervisor

JAVA QUESTION:

General Scenario:

You are creating an interactive application that gets input from the keyboard and keeps track of the residences that a supervisor takes care of. To develop this application, you will be using 2 interfaces,1 abstract class, 1 concrete class, and 1 driver class. You should use the 2 interfaces and 1 abstract class to create a concrete class. You must also create a driver class. Your application should have overridden toString() at appropriate places so that you could display the object state, i.e., the string representation of the objects that you create by simply using the following command: System.out.println(object).

Follow the following instructions:

1. Create 2 interfaces: BedInterface and WashroomInterface.

BedInterface contains only 1 abstract method: numBed() which returns an integer: number of bedrooms and does not take any arguments.

2. WashroomInterface contains only 1 abstract method: numWash() which returns an

Integer: number of washrooms and does not take any argument.

3. Create an abstract class named Building. This class contains 1 instance variable, 1 constructor, and 1 abstract method.

a. Instance variable: area (that will take care of the area of the unit, use appropriate data type.)

b. A 1-argument constructor that will be called from its subclass to load 1 instance variable of this level during the creation of an object in its subclass.

c. 1 abstract method: yearBuilt(). This method takes 1 argument: an integer yearBuilt that stores the year the building was built. This method does not return anything when sub classed into a concrete class. When subclassed into a concrete method, it would simply display the value of the area of the unit within itself..

d. In this abstract class Building, write necessary code to get the object state (i.e., the string representation; you need to override the toString() method.) that will eventually be called from its concrete subclass..

4. Create a concrete class named Residence that makes use of the abstract class Building and the 2 interfaces, BedInterface and WashroomInterface that you created earlier:

a. This class has 2 instance variables of its own, 1 constructor, and 1 concrete method of its own.

b. Instance variables: numBed (number of bedrooms) and numWash. (number of washrooms. Use appropriate data type for both.)

c. Constructor: 1 constructor that constructs a Residence object with all its instance variables (area, number of bedrooms, number of washrooms) supplied during the Residence object creation.

d. 1 concrete method of its own: yearBuilt() that does not return anything, takes 1 int argument yearBuilt. This method displays from itselt the year the residence was built .

e. Write all necessary code to make this class a concrete class.

f. Write necessary code to get the complete string representation (i.e., the object state; you need to override the toString() method) of objects made from this class.

5. Create a driver class named XXXMidTerm (replace XXX by three letters of your name). This driver class would prompt the user to enter area, number of beds, and number of washrooms in the residence. It then uses these user input to create a residence object. It would then display the string representation of the object you just created. And finally, it would ask for the year the residence was built. and would display the year it was built.

A possible test run would look like:

Enter area:

100

Enter number of beds:

3

Enter number of washrooms:

3

Your residence data as entered:

Building Area: 100

Number of Beds:3

Number of Washrooms: 3

Enter which year it was built:

2018

The buiding was built in : 2018

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 Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions