11/16/2020 Exercise 10
Exercise 10
Points 1
Before you start to do your weekly exercise, please make sure that you already go through this week’s lecture slides and tutorial document (can be found in Modules).
What are the exercises?
Please find the Coloured Balls codebase (ColouredBalls.zip) in Module 10 on canvas. This is the same codebase you have been given for your exercise 6 and exercise 9. You can use this provided codebase for this week’s exercise if you wish, but it would be better if you had a working implementation with both Strategy and Observer patterns implemented in what you are building on – the added complexity will help you to see what the patterns are actually doing for you in code. For example, what you will be doing with the Prototype pattern will work just as easily without strategies, but it will be severe overkill if the Balls only differentiate by colour. What you will be doing with Memento will show you how effective your Observer implementation is.
In this weekly exercise, you are going to continue your ball application by adding the following features:
A BallSpawner that allows new Balls to be added to the BallPit based on set parameters (colour, or colour and strategy) with random direction and speed (use the Prototype pattern)
A Save and Restore state function that allows a list of saved states of the BallPit to be recorded and restored at will (use the Memento pattern)
Note that, each of these should be controlled using buttons you add to the BallPit UI.
What are you expected to do?
Task1: Refactor this codebase by using the requested design pattern (i.e., Prototype and Memento) Task2: Model the codebase after refactoring in a UML class diagram
What are you expected to submit?
You need to submit two files, including a zip file (NOTE: you need to submit a .zip file instead of .rar or .7z or others) of your refactoring codebase (src folder and build.gradle), and a pdf file of UML class diagram with a brief description on how you applied these requested patterns on your code.
You can submit your solution any time before the due. 1 mark is awarded to you only if: You apply Prototype and Memento Patterns correctly on code and UML AND Your code compiles and runs successfully via gradle build and gradle run
Design Pattern Exercise with Code
Criteria
Ratings
Pts
Description of criterion
1.0 pts Full Marks
Applying requested design pattern(s) correctly on code and UML. Code can be compiled and run successfully.
0.5 pts Half Marks
There are major flaws in applying the design pattern(s) or code cannot be compiled or cannot be run or not follow the requirement
0.0 pts
No Marks
A poor or
minimal
attempt
has been made
Total Points: 1.0
1.0 pts