For this assignment you will make a animation of fireworks. This common animation is called a "starfield" since it can also be used to simulate movement through a field of stars. You may find slides 1 - 131 on OOP.pptx helpful.
Your program must use three classes to model the particles. A "Normal" particle class, an "Oddball" particle class and a "Jumbo" particle class. All the particles must be stored in a single array using an interface. The Jumbo particle class must use inheritance.
- Fork this repository
- First, finish the
NormalParticle
class. It will need the following members:
- 5 member variables: X and Y positions, Color, Angle and Speed. (Hint: use doubles for X, Y, Speed and Angle)
NormalParticle()
, the class constructorvoid move()
, Takes the cos of the angle times the speed and adds it to the X coordinate. Does the same to Y with the sin of the angle.void show()
, draws the particle in the correct color
- Now finish the program's
setup()
anddraw()
- Add one
NormalParticle
variable, and make sure you can see it move - Now modify the program so you have an array of NormalParticles.
- Run your program and make sure you can see all the particles move.
- Finish the Particle interface. It will list two methods:
public void show();
public void move();
- Have your NormalParticle
implement
the Particle interface. - Add
public
in front of themove()
&show()
methods in your NormalParticle class. - Create an OddballParticle class that
implements
the Particle interface. - Finish the
OddballParticle
class. It will be similiar to the NormalParticle, but OddballParticles should have differentmove()
andshow()
methods. - Change your array of NormalParticles to an array of type
Particle
. - Change the first element in the array to a OddballParticle instead of a NormalParticle
- Run your program. Make sure you can see the Oddball.
- Now, write a new Jumbo class that
extends NormalParticle
(orextends OddballParticle
). In this class you will only need to override the one methodpublic void show()
to draw a larger ellipse. - Change the second element in the array to a Jumbo instead of a normal Particle. Run your program and make sure you can see the Jumbo.
- Submit the url of your GitHub webpage via the school loop drop box for the assignment
Extensions: Have a fun and be creative. If you have extra time you may want to modify your program and add extra features. Experiment with different arrangements of particles. Look at student work from the links below for other variations.
Andy
John
Theo
Andre
Jesse
Emily
Edmund
Alexandria
Charlotte
Andy
Caleb
Nathan
Emily
Nicole
Anya
Thomas
Terrance
Michelle
Reesa
Aidan
Skyler
Steven
Megan
Veronica
Linda
Belinda
Kelly
Jeanette
Melanie
Belinda
Ivan
Helen
Elliot
Amy
Brian
Raymond
Brandon
Diana
Justin
Rebecca
Abhay
Leo
Victor
Sida
Brian
Thien
Tiger
Yang
Melody
Darren
Bryan
Thomas
Daniel
Miko
Kevin
Dmitry
Kaki
Evan
Charles
Leif
Martin
Matthew
Jimmy
Alex
Winnie
Brandi
Elston
David
Andrew
Esther
Brian
Justin
Alexander
Jeremy
Chris
Ryan