Program 4 - Graphical Objects

Goal Description Hints Passoff

Due Date - 7 Mar

Goal

 
  • Learn how to create objects with methods
  • Learn to build complex objects from simpler objects
 CS 142
Description
 

Your assignment is to create an animated person, This person can look any way you want (provided it is recognizable as a person.) Your person should be composed of the following classes:

  • Person - this is the class for the whole person. It is a subclass of Group so that it can be placed into a window or another Group. It uses the following classes to build itself.
  • Head - this is the class that controls the head. It should have the following methods:
    • setSkinColor(Color) - this will change the skin color of the head
    • setEyeColor(Color) - this will change the eye color of the head
  • Body - This is the body of the person (chest and abdomen) The body is also responsible for putting on clothes.
  • Arm - This class is for an arm. There should be two instances of this class in your Person. One for the left arm and one for the right. This class should have the following method.
    • setSkinColor(Color) - this will change the skin color of the arm
  • Leg - this class is for a leg. There should be a right leg and a left leg both of the same class. This class should have the method
    • setSkinColor(Color) - this will change the skin color of the arm

The Person class is the primary class that people will deal with. It will manipulate the head, body, arms and legs by calling their methods. The Person class should have the following methods:

  • setSkinColor(Color) - this will change the skin color of all of the relevant body parts.
  • setEyeColor(Color) - this will change the color of the eyes.
  • setLeftArmAngle(double) - this will set the angle of the left arm. 0 degrees points straight to the left, -90 degrees points the arm straight down, 90 degrees points the arm straight up.
  • setRightArmAngle(double) - similar to setLeftArmAngle() except that it points to the right.
  • setLeftLegAngle(double) - this will set the angle of the left leg. 0 degrees points straight down and 90 degrees points straight left.
  • setRightLegAngle(double) - similar to setLeftLegAngle()

 

Once you have your Person built, you need to build a main program. This program has a loop that asks the user for one of the following commands

  • "up" - if the user types this, then the person should stick their arms straight up
  • "down" - if the user types this, then the person should stick their arms straight down.
  • "blue" - turns the eyes blue
  • "brown" - turns the eyes brown
  • "tan" - gives the person a tan color
  • "pale" - gives the person very pale skin
  • "dance" - animates the person to do a little dance however you like by moving the arms and legs.
Hints
 
  • Each class should be in its own class file.
  • Person, Head, Arm, and Leg should all be subclasses of Group.
  • Though a left arm and a right arm are the same class, a simple rotation will leave one of the thumbs pointing in the wrong direction. Note that scaling by -1 will reflect an object about an access. This can help with the problem. Similar problems can occur with left legs and right legs.
  • Each class should have private variables for each of the paramters (angles, colors, smiling) that they control. Each class should also have private variables that point to the parts whose colors or rotations must be set.
  • START EARLY. This is a much longer problem than the previous ones.
  • Build each class one at a time and test it to be sure it works before going on to the next one. Build up step by step.
Passoff
 

__ 2) Good naming practices.

__ 2) Good use of public and private. Only what is necessary is public.

__ 2) Loop through all commands works correctly

__ 2) Person draws correctly

__ 2) Eye color changes correctly

__ 2) Skin color changes correctly

__ 2) Arms go up and down correctly

__ 4) Animation works correctly