Programming for Interactive Digital Arts
CS 2, Fall 2023

SA 9. Due: Fri, Oct 13

To try your hand at arrays, create a solar system by storing instances of a Planet class in an array.

Define a Planet class to store information about each planet — its rotation angle (this.a), radius (this.r), size (this.sz), color (this.c), and angular velocity (this.da);

Your sketch should create an array with 8 slots and fill it with 8 Planets, using new Planet() for each.

Your sketch should also draw a yellow sun in the center, around which the planets rotate at different speeds (angular velocities).

Your Planet class should define a constructor()--to initialize the class fields for angle (this.a), radius (this.r), size (this.sz), color (this.c), and angular velocity (this.da); a display() method to draw the planet using the class fields; and an update() method, to update the angle by its angular velocity.

Applet

As always, turn in the sketch (as a link) and a screenshot of your running program.