Question: Use the black screen to communicate with the user for input and output. Description of the Problem: RoomDimension class Your first task is to create

Use the black screen to communicate with the user for input and output.

Description of the Problem:

RoomDimension class

Your first task is to create a RoomDimension class with the following features:

it has three private data fields of type double: length of room, width of room, and height of room

it has a three-argument constructor to establish length, width and height for the room

it has a two-argument constructor to establish length and width. The height is set to a default value of 8.0 feet by this constructor.

It has a copy constructor to make a proper deep copy of values from another RoomDimension object.

It does not have a zero-argument constructor.

It has a getArea() method that will return the floor area of the room (i.e. length x width)

It has a getVolume() method that will return the volume of the room (i.e. length x width x height)

It has a toString() method to return the essential information about the object (length, width, height) in the form of a String. Be sure to present the information in a meaningful way such as: Room data: length = 14.0, width = 16.0, height = 8.0

Write a RoomDemo class to test that all features of this class are working properly. You figure out what should be tested and then demonstrate that it all works.

RoomCarpet class

Create a RoomCarpet class according to the UML diagram shown on page 555. It has a RoomDimension object named size as one of its fields. Note that this class does not contain separate

It also, has a carpetUnitCost field that is the cost per square foot of the carpet.

The RoomCarpet constructor includes a RoomDimension object and a double for cost per square foot.

Inside this constructor, you must call the RoomDimension copy constructor to make a deep copy of the RoomDimension object into the RoomCarpet object.

The getTotalCost() method will multiply the carpetCost by the floor area of the room. (Note that the floor area is obtained by using the getArea() method of the RoomDimension object.

The toString() method will return a String that represents RoomCarpet information. This method will, in turn, call the toString() method of the RoomDimension object to add the RoomDimension information to the carpet cost.

Run the following program code inside a loop allowing the user to cost many carpets

Your CarpetDemo class should ask the user for the length and width of a room in feet and for the cost per square foot for the carpet.

It then creates a new RoomDimension object, which is passed to the RoomCarpet constructor along with the cost per square foot of carpet to create a RoomCarpet object.

The CarpetDemo class will then display the dimensions of the room, the area of the room and the total cost for the carpet.

Note that the RoomCarpet class does not need the volume of the room even though it still exists in the RoomDimension class. This shows that classes may contain more features than are needed in each application. This is normal in object oriented programming.

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!