Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribed

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[.getMaxTemperatureO

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

ISBN: 0619064625, 978-0619064624

More Books

Students also viewed these Databases questions