Homework Assignment
You are welcome/expected to work on this assignment in lab today until 5pm,
so make good use of your lab time today!
The programming exercises below will be submitted as homework next week, due before 5pm on Tues, Nov 23. Those of you
leaving Sewanee early... are still subject to the same due date & time.
Now that your Fish is complete, it is time for you and your partner, if any, to split up
and start working individually on the homework.
Move to a computer away from them so you are not tempted to confer.
Since both of you fully understand the code you submitted together,
that is no longer necessary.
Your homework should be all your own work.
In all of the below, "random" means using Math.random() to get values in whatever
range is necessary.
Use the filenames specified in each of the below except where ??? and "your initials / AB"
should be replaced with specific values for your Java class & human name.
- (10 pts) Animation2Client.java
- Make an array of 10 fish where each is constructed
at random x & y coordinates on the window.
w & h are up to you.
All 10 should be entirely visible.
- Animate all 10 inside a for-loop similar to
the one in the
animation example code
from this morning.
There should be no constructions
and no color changes inside the animation loop.
Only mutations.
Make sure that when the fish stop moving, most of them are
still visible.
- After the animation loop, construct a random color.
Use this ONE random color to setColor on ALL 10 fish.
They should all be the same color now.
- (10 pts) ???_AB.java (AB replaced with your initials; ??? replaced with name of your thing)
Make a new shape (ie, not a fish!) of something you can draw that could logically
be expected to move. Keep it simple but recognizable. Should satisfy the following
- A minimum of 5 parts that are readily apparent.
- A minimum of 3 different types of parts (ie, ellipse, rectangle, line, text, arc, ...)
- No partial things. Must be a "complete" thing. (ie, not a just a face of something)
- A constructor that takes x,y,w,h and draws your shape in the same
"red design area" specified using x,y as upper left corner, w the entire width,
h the entire height that we used to develop the fish.
- A constructor that takes x,y,s and uses s for both w & h
- implements Ifc1, Ifc2
Ifc1.java
Ifc2.java
(Need ideas?)
- (10 pts) BorderClient.java
- Make a border for the window of alternating shapes (fish & ???), all the same size putting
all of them in the SAME array. That's ONE ARRAY TOTAL. Shapes should all be visible
and should not overlap one another. Assign a different random color to each of them.
Each side of border should have at least 8 fish in it.
- Ask user (scanner time!) if they would like to animate them. If so, all shapes should
move at the same speed in the same direction. No color changes!!! Stop the animation when
there's only a single vertical line of shapes still visible.
There should be no constructions
and no color changes inside the animation loop.
Only mutations.
- After the animation ends, change all the shapes to the same color.
You can choose what color but they must all have the same color.
- (10 pts) RaggedClient.java
- Make a 2D ragged array of alternating rows of shapes. One shape per row.
Row lengths start with 2 and go up to 8. (example)
- All shapes should be visible and none overlap.
- Every shape in a row has the same color but every row has a different color
- Animate the entire array (you can go any direction but once chosen should keep going that way.
You MUST USE YOUR ACCESSING METHOD(S) and A WHILE LOOP for this animation.
There should be no constructions
and no color changes inside the animation loop.
Only mutations.
- Stop when shape at [3][3] is still fully visible but one more translate would start
it off the window. You MUST RECOGNIZE WHEN TO STOP BY HAVING USED YOUR ACCESSING METHOD(S).
While your array will be of Ifc1 types, you will need to *also* assign the
shape in array at [3][3] to an identifier of type Ifc2 so that you can use
the accessor methods you need. Do not construct this shape more than once.
- After stop, setColor to all shapes in the array to Color.MAGENTA
- Follow coding standards in all files.
Due Date: 23 Nov by 5pm
HW Submssion should include:
- Animation2Client.java
- ???_AB.java
- BorderClient.java
- RaggedClient.java
I definitely already have Ifc1 & Ifc2.
And I _should_ already have your Fish already!
- If by some misfortune you did not send me your Fish & Client before 5pm on Thur lab,
include BOTH of these files as well.