Question: package modelobject; public class WashingMachine { private double maxLoad; private boolean hasDryer; public WashingMachine(double maxLoad, boolean hasDryer) { this.maxLoad = maxLoad; this.hasDryer = hasDryer; }

package modelobject;

public class WashingMachine { private double maxLoad; private boolean hasDryer;

public WashingMachine(double maxLoad, boolean hasDryer) { this.maxLoad = maxLoad; this.hasDryer = hasDryer; } //getters and setters public double getMaxLoad() { return maxLoad; }

public void setMaxLoad(double maxLoad) { this.maxLoad = maxLoad; }

public boolean isHasDryer() { return hasDryer; }

public void setHasDryer(boolean hasDryer) { this.hasDryer = hasDryer; } //load method loads clothes in the washing machine public void loadClothes(double load){ if(load>maxLoad){ //if the load is greater than the maxLoad System.out.println("That is too many clothes! Max Load: "+maxLoad+" pounds"); }else{ //else the clothes are loaded System.out.println("Clothes are loaded!"); } } //wash method washes the clothes public void wash(){ System.out.println("The clothes have been washed!"); } //dry clothes method public void dryClothes(){ //if the hasDryer method is true if(hasDryer) System.out.println("The clothes have been dried!"); else System.out.println("This washing machine has no drying feature.");} } public class Week1 {

public static void main(String[] args) { //instantiating a WashingMachine object WashingMachine washingMachine = new WashingMachine(16.9,true); washingMachine.loadClothes(45.0); washingMachine.loadClothes(10.0); washingMachine.wash(); washingMachine.dryClothes(); }

}

Correct based on the feedback's which are

Its better practice to use descriptive variable/object/parameter names to improve readability and maintenance

Brand would be a good attribute to use and would give you a better way to use descriptive variable names

and add encapsulation to it to include making all attributes private, adding constructor, and adding get and set methods. The main method should create an instance of the class and demonstrate the correct functionality of all the methods.

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!