- The Design document must be in PDF
- For the code the entire project MUST be submitted (not just the source files)
- The project must be named (in Eclipse) with the following format LabNumber_FirstName_LastName_AssignmentNumber _StudentNumber, e.g. 104_Jim_Silvester_Assignment1_1234567
- To submit, export the project (including all the libraries used) into a zip file (Archive File) and name it exactly the same as the project name (Please note failure to meet any of these submission requirements above would result in a penalty of 0.25 pt each)
- No late submission will be accepted. If you do not complete the assignment by the deadline, you will receive 0. For a legitimate reason a late submission might be allowed pending discussion with your TA before the deadline. You may be required to provide supporting documents.
- For the coding, make sure your code is syntax error free so that it runs properly on the lab machine. You would receive 0 for the coding part if your code failed to run due to syntax errors.
- Requirements are the same as Milestone 1
- To demonstrate that you learned the relevant concepts, you need to answer an online assessment on the work you’ve done.
- The assessment will be posted in Canvas and available right after the due date. You’ll have 20 minutes to do it. Make sure you do it in time to get full credit for your assignment. Please note once the online test is closed by the end of its schedule, NO Make-Up is possible. So it is your responsibility to make sure you do it in time to get full credit for your assignment.
For the UML design document, you are graded on completeness and correctness, and for the code on completeness and visual style.
By doing this assignment you will learn how to:
- Design Encapsulation with UML
- Draw graphic primitives (arc, oval, triangle, quad etc.);
- Compose complex shapes with primitives;
- Animate the complex shape with translation and rotation;
- Create a class as a container to hold properties and methods for the shape;
- Instantiate an object and call its methods.
First of all, this assignment must be done using Java System Library. You will get 0 if you use Processing library or any other 3rd party libraries.
This assignment has two iterative steps: Milestone 1: initial UML design and drawing the fish and Pond, and Final Deliverable: updated UML design and animating the fish
1) Download VioletUmlEditor 2.1.0 and use it to draw the initial UML that should include the Fish class that is designed with strict Encapsulation with minimal public interface methods. The UML diagram must follow the UML notations for class and encapsulation. Also the names of the class, fields and methods must follow the naming convention with appropriate upper- or lower case for the initial and CamelCase thereafter
2) Create the JFrame window and JPanel subclass for FishPanel by following the examples of lecture and/or lab (It’s OK for now if you don’t fully understand them, just follow the example and do it)
3) Draw the pond: In the FishPanel class, create a method and name it drawPond, which draws a rectangle filled with appropriate color, and objects (weeds, stones, bubbles, corals etc.) to simulate the pond. Please note the pond size must be smaller than the display window by at least 10 pixels on each of the sides. Then display the pond by calling it in the paint() or paintComponent() method
4) Create the Fish class, which should incorporate all the properties and methods as per the UML design, plus a constructor that initializes each of the fields with some parameter
5) The Fish class should have a drawFish method that draws a fish, which must have the following features (you can do more though):
- A head (made of arcs and/or other primitives that you feel appropriate) with an eye and a gill
- A body made of appropriate primitives and decorated with scales, stripes, or dots
- At least two body fins made of appropriate primitives (arc, triangle, quad, polygon etc.) and decorated differently from the body
- A tail decorated differently from the body and body fins
(Please also refer to Section 2.3 below, the last digit of your student number matters to your feature design. For example, if the last digit of your student number is 1, and you decorated your fish body with dots and scales only, you are still missing a feature.)
Submission of milestone 1: submit both the initial UML design and code per the submission requirements and the deadline as specified in Section 1.
1) Update the UML design by including FishPanel class and its relationship with the Fish class (aggregation). Then make the FishPanel implement ActionListener (Again it’s OK for now if you don’t fully understand them, just follow the example and do it)
2) Add a Timer object as field to FishPanel
3) Make the FishPanel implement ActionListener and thereby the method it declares
4) Add the field of Timer(Make sure you use javax.swing.Timer rather than java.util.Timer), and then initialize it with a new instance and start it within the FishPanel constructor
5) Within the drawFish(Graphics g) method, type cast the graphics instance g into an instance of Graphics2D, so that we can apply transformations with it
6) Animate the fish: create a method for moving (to be descriptive, name it either update or move), it will work together with drawFish method to render and animate the fish. They would:
- Move the fish from left to right to simulate fish swimming (must involve translation)
- When it hits the edge of the pond, it should turn around and moves in reverse direction
- When the fish turns around, its tail must not go out of the boundaries of the pond
- The process will repeat (i.e. the fish will swim back and forth within the pond repeatedly)
7) Please note the method for move must be called inside actionPerformed() method, and then call repaint() for the animation to be functioning.
Submission of Final Deliverable: submit both the updated UML design and code per the submission requirements and the deadline as specified in Section 1.
Please note visual style counts! Try to be original and creative when designing your pond and fish, and there will be marks allocated for evaluating the esthetic aspects of your visual design. Beyond those required features listed above, depending on the last digit of your student number, you must have at least one of the following features in your fish*.
- 0 : Your fish body must be decorated with scales made from arc
- 1 : Your fish body must be decorated with stripes
- 2 : Your fish body must be decorated with dots
- 3 : Your fish body must be decorated with scales made of triangles
- 4 : Your fish tail must be made of triangle(s)
- 5 : Your fish tail must be made of arcs
- 6 : Your fish tail must be made in shape like an opened scissors
- 7 : Your two body fins must be made of one triangle and one quad
- 8 : Your body fins must be made of one arc and one quad
- 9 : Your body fins must be made of quads
- If you feel that your required feature will affect your design as a whole, talk to your TA or instructor. We may relax the constraint if your design sounds reasonable.
You can win up to 2 pts bonus marks by adding some animated features to your fish, e.g. mouth opening/closing or eye ball moving (up to 0.5), tails and/or fins flapping in certain way (up to 1 pt), making the fish move in waving pattern (i.e. moving forward with up and down oscillations , up to 1 pt), or animating objects in the pond, e.g. making seaweeds wave (up to 1 pt), bubbles moving up and popping at the surface (up to 1pt), or some other equivalent features that you might come up with. Please note the bonus caps at 2 pts even if the add-up of your bonus features goes over it.