Question: Can you help me modifying this java class Modify the Room class by adding the following methods: Method 1: hasAdequateCooling The purpose of this method
Can you help me modifying this java class
Modify the Room class by adding the following methods:
Method 1: hasAdequateCooling
The purpose of this method is to check the rooms air conditioner to see if it has a high enough cooling capacity to adequately cool the room.
For example, a Moderately Shaded room that is 500 square feet requires an air conditioner with a capacity of 10,000 BTUs per Hour. If that room has an air conditioner with a cooling capacity of 8,000 BTUs per Hour, then that room does not have adequate cooling.
The method should not accept any arguments, and should return true if the room has adequate cooling, and false if the room does not.
Method 2: toString
Use this method to display all of the relevant information of the Room class (including its AirConditioner)
here is the code
public class Room { //Filed private String name; //name private double length; //length private double width; //width private String amountOfShade; //amount of shade private double cooling_capacity;// cooling capacity private final double LITTLE_COOLING_CAPACITY=0.15;// little room shade capacity increased by 15% private final double ABUNDANT_COOLING_CAPACITY=0.1;// Abundant room shade capacity decresed by 10% private AirConditioner airconditioner;// instance of the airConditioner class /** Constructor @param nam the name of the room @param len The length of the room. @param w The width of the room. @param cooling_capacity the capacity of the room @param airconditioner a AirCondioner object */ //no-arg constructor public Room() { name=""; length=0; width=0; amountOfShade=""; cooling_capacity=0; } public Room(String name,double length,double width,String amountOfShade,AirConditioner AC) { this.name=name; this.length=length; this.width=width; this.amountOfShade=amountOfShade; this.airconditioner=new AirConditioner(AC); } /** The setName method stores a value in the name field. @param name The value to store in name. */ public void setName(String name) { this.name=name; } /** The setLength method stores a value in the length field. @param length The value to store in length. */ public void setLength(double length) { this.length=length; } /** The setWidth method stores a value in the width field. @param width The value to store in width. */ public void setWidth(double width) { this.width=width; } /** @param airconditioner-AirConditioner object. */ public void setShade(String amountOfShade) { this.amountOfShade=amountOfShade; } /** The setCoolingCapacity method stores a value in the cooling_capacity field. @param cooling_capacity The value to store in cooling_capacity. */ public void setAirConditioner(AirConditioner AC) { this.airconditioner=new AirConditioner(AC); } public String getName() { return name; } /** The getLength method returns a Room object's length. @return The value in the length field. */ public double getLength() { return length; } /** The getWidth method returns a Room object's width. @return The value in the width field. */ public double getWidth() { return width; } /** The getShade method returns a Room object's shade. @return The value in the shade field. */ public String getShade() { return amountOfShade; } /** The getCoolingCapacity method returns a Room object's cooling_capacity. @return The value in the cooling_capacity field. */ public double getCoolingCapacity() { return cooling_capacity; } /** The AirCondition method object's area. @return The reference to copy of this Room's AirConditioner object. */ public AirConditioner getAirConditioner() { return new AirConditioner(airconditioner); } /** The getArea method returns a Room object's area. @return The product of length times width. */ public double getArea() { return (length*width); } /** Method for cooling capacity @return the capacity */ public double calCoolingCapacity() { double area=getArea(); double capacity; if(area<250) { capacity=5500; } else if(area>=250&&area<=500) { capacity=10000; } else if(area>500&&area<1000) { capacity=17500; } else capacity=24000; if(amountOfShade.equalsIgnoreCase("Little")) { capacity=capacity+capacity* LITTLE_COOLING_CAPACITY; } else if(amountOfShade.equalsIgnoreCase("Abundant")) { capacity=capacity-capacity*ABUNDANT_COOLING_CAPACITY; } return capacity; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
