CST 112 -- Final Exam

Your code for final program must be submitted today, in a file named t6.pde.

Below are descriptions of objects, properties, methods, and other details, along with instructions about features provided and actions performed by your program. The "demo" at t6/t6demo.bam provides working code to illustrate most features.

The "starter" code at t6/t6starter.pde already contains the class definition for the Person object; add you own code as necessary to complete the required features. (No mods are required for Button class, which is also provided.)

Additional features for the in-class portion of the final exam:

  1. Add a sun that keeps moving slowly across the sky.
  2. Add a bird that flies back and forth in the sky.
  3. Draw a row of few small trees in the background, behind the people.

  4. Animate the Person objects; animate the bird. (Add your code to show() method of Person class.)
  5. Below the people, draw a grassy field, with flowers growing across a portion of the bottom. (Use a loop, and try to make the spacing random between the flowers.)

  6. Click on any Person object to cause it to go on a diet: Call the diet() method for that one object, only.
  7. Use the following formula to compute the BMI index:

Takehome portion of the final exam (due today):

The program ("t6") should display six Person objects -- each representing the properties and methods of a person.

Buttons (when clicked) should perform the following tasks: * indicates tasks for which you added your own code.

reset
Reset all objects. (NOTE: reset() is provided in starter code.)
age-sort
Sort the objects by age. (NOTE: ageSort() is provided in starter code.)
bmi-sort *
Sort the objects by bmi.
pounds *
Sort the objects by pounds.
short-tall *
Sort the objects by from shortest to tallest.
tall-short *
Sort the objects by from tallest to shortest.
Year-all *
Call the year() method for all Person objects.
Diet-all
Call diet() method for all Person objects. (NOTE: dietAll() is in starter code.)
quit
exit();
NOTE: keyPressed() starter code already defines a key for most of these tasks.
Add your code to mousePressed() to connect the buttons.
In some cases, you must also add code to the functions, to perform the task.

Averages must be computed for the following properties:


Person has the following properties:

	class Person {
 
	  // PROPERTIES //
	  String name="___";
	  int age;         // Age (years)
	  float tall;      // Height (pounds).
	  float wide;      // Width (inches)
	  float pounds;    // Weight (pounds)
	  float bmi;       // BMI index.
	  color c;
	  int scale=4;    // (4 pixels per inch)
	  float x, y, glance=0; 	// Animation.
           // Every few seconds, glance changes random(-1,+4).
Person does the following methods:
  // METHODS //
  void show( int xx, int yy)  // Set (x,y) coordinates & show();
  void show( )  	// Display the object.
  float bmi()  		// Computer BMI index (from height and weight)
  void diet() 		// Reduce width & pounds
  void year()  		// Add one year to age (and adjust properties)
  boolean clicked()  	// Return true iff clicked
  boolean hit( float xx, float yy ) 	// True iff (xy) hits object.

  // CONSTRUCTORS //
  Person( String n) { 
    this.name = n;
    randomize();
  }
  void randomize() 	// Randomize the properties. ("reset")

}// class Person