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.

(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
Get step-by-step solutions from verified subject matter experts
