Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Override the toString method in class Washer as follows: If loadGarnment has never been called, it must print An empty washer. If loadGarnment has been
Override the toString method in class Washer as follows: If loadGarnment has never been called, it must print An empty washer. If loadGarnment has been called at least once, it must print A washer with XX jeans, YY t-shirts, and ZZ socks, where XX, YY, and ZZ should be the number of instances of class Jeans, TShirt, and Socks, respectively. For example, line 19 should print: A washer with 2 jeans, 1 t-shirts, and 1 socks.
Source Listing import clothing. import appliances.* 4. public class TestL aundry final double WASHER SIZE 19.6: public static void main (Stringll args) washer washer-new Washer((int)WASHER SIZE); Clothing[I laundry new JeansO, new JeansO. new TShirto, new SocksO : 12 try t for (Clothing garnment: Laundry) 15 16 washer.loadGarnment (garnment): catch washerFutlException ex) i System.out.printin"WARNING: Washer is full. Cannot add any more garnments."): 19 20 21 System.out.println (washer): System.out.println( Can hash proceed?hasher. isTemperatureok(9e.2)): 23. package appliances: 25 class WasherFullException package appliances 26 27. 28.mport clothing.Clothing: 29. mport java.lang.RuntimeException; 30 31.Class Washer t 32 private int capacity: private Clothing[ load private int loadsize: 35 36 37. 38 public WasherO tY public Washer (int capacity) t if (this.capacitye) 41 42 43 throw new RuntimeException("capacity must be >:capacity): this.capacity- capacity: this.loadnew Clothing[this.capacityl: 45 public void loadGarnment (Clothing garnment) throws WasherFullException t 47. if (loadsizecapacity) 48 load[loadsize- garnment: 49 else throw new WasherFullExceptionO: 51 52 53 54 public boolean isTemperatureoK (double temperature) t for (int 16: 1 load. length: t if (load[.getMaxTemperatureOStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started