NOTE: THIS CLASSWORK CAN BE TURNED IN BY MARCH 16.
Today's classwork focuses on using graphics, inheritance, and lists to draw a
number of random colored circles, going different directions and
speeds, bouncing around within the canvas. This basic functionality
is similar to what is required for basic simulation of molecular dynamics.
Snarf the 12-moreAnimation-cps006-spring10 to get started. You can see the code here.
BouncingBall object of type Dimension. Demonstrate
how you can create and display two BouncingBalls of
different sizes.
Canvas class to use a collection (i.e., an ArrayList) to hold the
BouncingBall objects it displays and updates.RED bouncing balls of the same size. What happens if they all have the same initial position and velocity? Include your answer in your README.
Canvas method,
addBouncers,that add the given number of
BouncingBall objects to the object's
ArrayList of BouncingBalls with the following additional
random attributes: BouncingBall created moves, i.e.,
does not have a velocity of (0, 0)? Include your answer in your README.
The origin of the bright yellow smiley face is not completely clear. The
earliest known examples of the graphic are attributed to Harvey
Ball, who devised the face in 1963 for a Worcester,
Massachusetts, USA-based insurance firm, State Mutual Life
Assurance. Ball never attempted to use, promote or trademark the
image and it fell into the public
domain in the United States before that could be
accomplished. It rose to popularily in the seventies and was
recently given the rare honor of appearing on a
postage stamp, becoming the spokesperson for Wal-mart, being one of the first structures modeled with DNA, and, of course, a representation of our emotions during text-based conversations as emoticons.
This problem asks you to create a class that represents a bouncing smiley face. Since that is similar to a bouncing ball, we will create a BouncingSmiley class that extends BouncingBall. Get that working first for a different color, and then add the face.
BouncingSmileythat represents
a smiley
face that can bounce off the walls like a BouncingBall.
Your BouncingSmiley and BouncingBall
classes likely share a lot of code. Make
BouncingSmiley a subclass of
BouncingBall, so that they share some state and
velocity and color.
Canvas constructor
so that it creates two BouncingSmiley objects
of different positions, sizes and colors in addition to the original
BouncingBall objects, so you should have two bouncing balls
and two bouncing smileys.
Your smiley face should have at least a head, two eyes, and mouth that are correctly positioned and sized proportionally to the canter and size given when the class is created. Note that you will need to change the pen color before drawing the eyes and mouth. Feel free to be creative about adding extra features to your smiley face (e.g., a hat, nose, teeth, headband, etc.).
Note:
Canvas method,
addSmileys,that adds the given number of
BouncingSmileys with random initial position and
velocity to the list of BouncingBalls.
Create a README file with your name, any persons you received help from, resources used, and answers to questions.
Submit via Eclipse your Java code and README file to the ClassworkMar2 folder.