Program 5 - Animated Dancers

Goal Description Hints Passoff

Due Date - 28 Mar


Use classes and arrays to create a troupe of animated dancers. In the process you will use loops for animation, create subclasses to add new functions and use arrays to create groups of objects.
 CS 142

Your assignment is to create a formation of dancers somewhat like the figure below. It is recommended that you have better looking dancers than these.

Step 1

You should first ask the user for how many rows of dancers they want. The user should be allowed to enter any number between 1 and 5. If they enter an incorrect number you should ask again.

You should next ask the user for the number of dancers in each row. This should be a number between 1 and 5. If they enter an incorrect number you should ask again as many times as are necessary to get a correct input.

Step 2

Create a class called Dancer that is a subclass of your Person class. Create a class called DanceTroupe that is a subclass of Group to contain all of your dancers. Give it a constructor that accepts the number of rows and the number of dancers per row. Test your DanceTroupe class to make certain that it displays all of your dancers correctly.

Step 3

Design three different poses for your dancer: poseA, poseB and poseC. A pose is defined as a particular set of angles for the arms and legs. Your poses can be anything that you want provided your set of poses cover leg movement, arm movement. I would test these poses by creating the methods setPoseA(), setPoseB() and setPoseC() on the class Dancer. I would also use the setScale() method to reduce the size of the dancers. I would also add setPoseA(), setPoseB() and setPoseC() methods to your DanceTroupe class. These methods should call the corresponding methods on each dancer in the troupe. These methods will let you easily tell all of your dancers to adopt the same pose.

Step 4

Add the methods setPoseAtoB(double), setPoseBtoC(double) and setPoseCtoA(double) to your Dancer class. The purpose of these methods is to set the pose somewhere between the key poses A, B and C. For example

  • setPoseAtoB(0.0) will set all of the angles to pose A.
  • setPoseAtoB(0.5) will set the pose angles to half way between A and B.
  • setPoseAtoB(1.0) will set the pose angles to pose B.
  • setPosetAtoB(0.25) will set the pose angles one quarter of the way between A and B.

Once you have these methods you can ask your dancer to assume any pose that is part way between any of the three key poses that you created in step 3.

Step 5

Modify your DanceTroupe class to have the same methods in step 4 and have those methods call the methods on each Dancer in the DanceTroupe. This will allow you to pose every dancer in the DanceTroupe all the same.

Step 6

Create a main() method that will ask the user for the inputs in step 1, set up the troupe and then use the pose methods to animate all of the dancers in the troupe to perform some dance of your choosing. You should use other methods so that your main() is not one long stretch of code. You should break down your problem appropriately with methods for each major step.

Your animation will be a series of loops that vary the pose parameter between 0 and 1 to move the dancer between poses.

  • The sample code GirlMain and Girl provide examples of arrays and animation.
  • It would be useful if DanceTroup were a subclass of Group. That will let you move the troupe around as a graphical objects.
  • You will need a two dimensional array of dancers in each DanceTroupe.
  • If you have an interpolation value t that varies between 0.0 and 1.0, and you have a start value S and and end value E, you can compute all of the interpolated values between S and E using the formula V=t*E+(1.0-t)*S. If you put 0.0 in for t you will get S and if you put 1.0 in for t you will get E. This formula will provide an easy mechanism for implementing the setPoseAtoB(t) methods.

__ 2) Code is well organized in classes and methods, each with a clear purpose and consistently with the specification above.

__ 2) Asking the user for input works correctly and will re ask any number of times until a valid answer is given.

__ 4) The correct number of dancers appears on the screen and is fully visible.

__ 4) All of the dancers dance in synchrony moving arms, legs and heads.

__ 2) The setPoseAtoB(t), setPoseBtoC(t), setPoseCtoD(t) methods are implemented correctly and are used to implement the animation.