AdaCore University

Stars 03 - Arrays

Download Lab Files


  • Create an enumerative type for star kinds with {Sun, Earth, Moon, Satellite} and an enumeration for metrics with {Speed, Distance, Angle}. Create two arrays, one array of one dimension containing the different shapes to store, and one array of two dimensions for the various metrics to store.

    Initialize the various values of the array with the following semantics:
    - Speed: angle step (in radian) that has to be added to the star angle at each iteration
    - Distance: distance from the star to the previous one (does not have any sense for the Sun star). This distance is computer in arbitrary board units.
    - Angle: current angle between the star and the previous star (does not have any sense for the Sun star). This angle may be initialized by 0.

  • Create an infinite loop in which each iteration moves the four stars by one predefined step. Each object is supposed to rotate around the previous one in the star kind enumeration. In order to avoid having an active loop, use a delay statement in the loop.
    Refine the values chosen in the previous question in order to have a nice movement.