Question: (c) Refactor your code so that the setColour method will throw an exception if it receives a parameter value other than Green, White or Gold.

(c) Refactor your code so that the setColour method will throw an exception if it receives a parameter value other than Green, White or Gold. The method should not be case-sensitive either, so green, white or gold should be acceptable. Show how you handle the exception.

(c) Refactor your code so that the setColour method will throw an

(b) The Java code below illustrates how a Drawing object may be composed of another Drawing object and Shape objects such as a Circle. Using an appropriate Design remaining code that would be required to make this code run to produce the output shown below (c) Refactor your code so that the setColour method will throw an exception if it receives a parameter value other than Green", "white" or "Gold". The method should not be case-sensitive either, so "green", "white" or gold" should be acceptable. Show how you handle the exception. Pattern as your guide, write the public static void main(String args) Shape tril new TriangleO Shape tri2 = new Triangle(); Shape cir1 new Circle(); Drawing drawing = new Drawing(); Drawing drawing2 new Drawing(); Drawing drawing3-new DrawingO; drawing3.add(tri2); drawing2.add(tri); drawing2.add(drawing3); drawing1.add(cirl); drawing1.add(drawing2); drawing1.setColourC"Green drawing2.setColourC"White drawing3.setColourC"Gold; drawing1.printO; Output Drawing Circle with color Green Drawing Triangle with color White Drawing Triangle with color Gold

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!