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.
|