Question: I need help with this question. I having trouble understanding this question below. It will be very grateful for you to help me with the




I need help with this question. I having trouble understanding this question below. It will be very grateful for you to help me with the questions. THANKS The CreateNewOp() method in DrawingUndoStackSimulation has a return type of DrawingOp. This method randomly creates and returns one of 8 different operations. In cases 4-7, a ColorOp object is created and added to the myOpStack, even though it is not a DrawingOp. How is this possible? L 11 12 public class colorop extends Drawingop private String colName; 14 1 16 17 18 19 public Colorop (String name, String colName) { super (name); this.colName = colName; } 20 @Override public String toString() { return super.toString() + " StateOpl" + "colName=" + colName = ''; 22 23 24 25 26 public class Drawingop { private String name; 13 14 15 public Drawingop (String name)! this.name = name; 1 17 18 19 20 TE 22 23 24 public String getName() { return name; } - public void setName (String name)! this.name = name; } 26 27 28 29 0 @Override public String toString() { return "Operation" + "name=" + name +'}; 31 32 private Drawingop createNewOp() { int opName = (int) (Math.random()*5); DrawingOp op = null; switch (opName) { case 0: op = new DrawingOp ("Draw Line"); break; case 1: op = new Drawingop ("Draw Rectangle"); break; case 2: op = new Drawingop ("Draw Oval"); break; case 3: op = new Drawingop ("Draw Curve"); break; case 4: op = new Colorop ("Change Line Color", "red"); break; case 5: op = new Colorop ("Change Line Color", "blue"); break; case 6: new Colorop ("Change Fill Color", "yellow"); break; case 7: new Colorop ("Change Fill Color", "black"); break; op = Op = return op
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
