Question
1. Consider the example in Assignment 1 (a canvas that can draw only circle and rectangle, disregarding Styles). Follow the Factory Method Pattern, draw a
1. Consider the example in Assignment 1 (a canvas that can draw only circle and rectangle, disregarding Styles). Follow the Factory Method Pattern, draw a class diagram that include these classes: Shape, Circle, Rectangle, Canvas, as well as other classes necessary. Remember to include proper connections, and necessary attribute/method definitions in your class diagram.
2. What is the role of the Canvas class in your design: is it part of the Factory Method Pattern, or is it something external to the pattern? Justify your reasoning. .
3. Write some necessary sketch code for the classes you defined in Q1, that is enough to demonstrate the process of drawing a circle on a canvas. You may describe the details of methods/functions with comments (no need to write actual code)
4. Describe a scenario where the Factory Method might become insufficient, and that Abstract Factory might be better, e.g. such as introducing new elements like the Styles of the Shapes. No need to write code or draw diagram.
5. Open question: in the course project, if you were to use either Factory or Abstract Factory, how would you apply these patterns? Note that there are other Creational patterns that we havent covered, so this question is to encourage you to start thinking about potential design.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started