Take a look at the class diagram and code for paint. The class diagram is in model.png, view.png and controller.png a) Factory Design Pattern: Reason to use: - Want dynamic user control of which instance of a subclass is created for example at runtime. - When construction of an object is complex, or involves the construction of other objects. http://www.oodesign.com/factory-pattern.html a1) Identify the Paint application classes involved in the Factory Design Pattern Client: YOUR ANSWER GOES HERE Factory: YOUR ANSWER GOES HERE Product: YOUR ANSWER GOES HERE ConcreteProduct: YOUR ANSWER GOES HERE a2) What is the Factory Design Pattern used for in the Paint application? YOUR ANSWER GOES HERE b) Strategy Design Pattern Reason to use: - Ability to switch out different implementations of a concept for different situations. https://www.oodesign.com/strategy-pattern.html b1) Identify the Paint application classes involved in the Strategy Design Pattern Context: YOUR ANSWER GOES HERE IStrategy: YOUR ANSWER GOES HERE ConcreteStrategyA: YOUR ANSWER GOES HERE ConcreteStrategyB: YOUR ANSWER GOES HERE ConcreteStrategyC: YOUR ANSWER GOES HERE b2) What is the Strategy Design Pattern used for in the Paint application? YOUR ANSWER GOES HERE c) Observer/Observable Reason to use: - O Wants to react to changes in state of object M without having to burden M with what O needs from M to correctly react. - Allow many such O's to independently subscribe to M for an update when M changes. Observer/Observable Design Pattern - https://www.oodesign.com/observer-pattern.html NOTE: ConcreteObservableA and ConcreteObservableB are mislabelled, they should be ConcreteObserverA and ConcreteObserverB. c1) Identify the Paint application classes involved in the Observer/Observable Design Pattern Note that this is not included in the class diagrams, so you will have to take a look at the code. Observable: YOUR ANSWER GOES HERE ConcreteObservable: YOUR ANSWER GOES HERE Observer: YOUR ANSWER GOES HERE ConcreteObserverA: YOUR ANSWER GOES HERE ConcreteObserverB: YOUR ANSWER GOES HERE c2) What is the Observer/Observable Design Pattern used for in the Paint application? YOUR ANSWER GOES HERE d) Command Design Pattern Reason to use: - Capture a dynamic sequence of operations needed to carry out a task. - Want to create a sequence of comands that are executed in order. The executor does not need to know anything about what the commands do or how they do it. The Executor simply tells each command, in order, to execute. - Supports Undo/Redo functionality. http://www.oodesign.com/command-pattern.html d1) Identify the Paint application classes involved in the Command Design Pattern Client: YOUR ANSWER GOES HERE Receiver: YOUR ANSWER GOES HERE Invoker: YOUR ANSWER GOES HERE Command: YOUR ANSWER GOES HERE ConcreteCommandA: YOUR ANSWER GOES HERE ConcreteCommandB: YOUR ANSWER GOES HERE ConcreteCommandC: YOUR ANSWER GOES HERE d2) What would have to be done to the Paint application to introduce an Undo button and then to make it functional? Describe the algorithm implemented by the Undo button controller. YOUR ANSWER GOES HERE Here is how this code works: MouseEvents are sent to an appropriate ShapeManipulatorStrategy, which understands how to create the currently selected shape. The ShapeManipulatorStrategy's job is to create and modify PaintCommands added to the PaintModel. To draw the screen, the PaintModel is consulted, and the list of PaintCommands are executed in order, effectively drawing the screen. Here are a few events, and how the code handles them. The user clicks the Circle button on the ShapeChooserPanel. The button fires the handle event handler in the ShapeChooserPanelController which asks the ShapeManipulatorFactory for a CircleManipulatorStrategy This new CircleManipulatorStrategy is installed in the PaintPanelController. Note that all Canvas mouse events are sent to the PaintPanelController and then forwarded on to the new CircleManipulatorStrategy. Next the user presses the mouse button on the Canvas in the PaintPanel. The mousePressed event is fired on the Canvas in the PaintPanel, this is routed through the PaintPanelController to be handled by the installed CircleMaipulatorStrategy. The CircleManipulatorStrategy creates a new CircleCommand and adds it to the Commands in the PaintModel. The PaintModel notifiesObservers, which causes the PaintPanel to repaint. The repaint clears the canvas and then executes all commands in the paintModel effectively redrawing the screen. Note: The CircleManipulatorStrategy holds onto the newly created CircleComand. Next the user drags the mouse across the Canvas in the PaintPanel. The mouseDragged event is fired on the Canvas, this is handled by the CircleMaipulatorStrategy. The CircleManipulatorStrategy modifies the radius of the CircleCommand it created above. This modification to the CircleCommand is a modification to the PaintModel, so the PaintModel notifiesObservers, which causes the PaintPanel to repaint. The repaint clears the canvas and then executes all commands in the paintModel effectively redrawing the screen. This time, the CircleCommand has a different radius. This is why you see the circle radius change when you drag. Next the user clicks the Rectangle Button on the ShapeChooserPanel. The button fires the handle event handler in the ShapeChooserPanelController which asks the ShapeManipulatorFactory for a RectangleManipulatorStrategy This new RectangleManipulatorStrategy is installed in the PaintPanelController. Note that all Canvas mouse events are sent to the new RectangleManipulatorStrategy.