Question: Exercise 1 in JAVA: The following figure shows a UML diagram that aggregates the RogmCarpet class from the RoomDimension class -rOom: : double ttalcost: double


Exercise 1 in JAVA: The following figure shows a UML diagram that aggregates the RogmCarpet class from the RoomDimension class -rOom: : double ttalcost: double r, double cost) t gtotalcost ): double t tostring): String other): boolean ime -length: double width: double double l, double w) gettength ): double + getwidth): double +tostring): String . length and width are in feet apCost is the cost of the carpet per square foot. totalCO is the total cost to carpet the room. Constructor Room^arpet(RoomDimension r, double cost) sets the attribute room to r, carpetCost to cost, and finds the total cost to carpet the room (that is, length*width carpetCost) and sets totalCost to this value getTotalCost); returns the value of the totalCost attribute * * toString() method in RoomDimension returns the length and width * toString() method in RoomCarpet returns the size (length and width), cost per square foot and total cost. (Note: You must use the toString method of the RoomDimension class here) * costsMore(RoomCarpet other): returns true if the total cost of carpeting "this" room is more tharn the total cost of carpeting another room (other), and false otherwise Implement the two classes. Test this in a demo program RoomCarpetDemo.java that prompts a user to enter values of two rooms of different sizes and carpet costs, and displays if the first room costs more to carpet than the second room using the costsMore method. Test it for at least three different input sets. Here's a sample screen dialog Enter the dimensions of the first room: 10.5 12.5 Enter the cost per square foot of carpet 10.00 Enter the dimensions of the second room: 20.0 15.0 Enter the cost per square foot of carpet: 7.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
