Wednesday, November 26, 2008

11/26/08 In class exercise review

Assignment 1:

Suppose you have a Town class that describes the demographics of small towns. The vital statistics described by this class are numberOfAdults and numberOfChildren. These vital statistics are encapsulated and not directly accessible from outside the class.

Write an initialize method that establishes initial values of instance variables. Write a simulateBirth method which simulates the birth of one child. Write a printStatistics method that prints out the current vital statistics.

Write a main method that creates a town called newHome. Then call initialize to establish initial values for newHome. Simulate the birth of a pair of twins and print out newHome's statistics.

---

Assignment 2:
Suppose you are asked to model plants using an OOP program. For each of the following plant-related entities, specifiy the most appropriate item to use for its implementation. For each entity, select one of the following: instance variable, object, method, or class.
  1. plant height
  2. sequence of activities that occur when a seed germinates
  3. an indication of whether a plant contains a vascular system
  4. an individual plant

Please list on your blog 1-4 and whether you believe each would be handled best as a(n) instance variable, object, method, or class.

----

Assignment 3:

Think of a possible "final project" that you could possibly accomplish. Please write an idea or two on your blog!

----

Assignment 4:

See how well you do on this:

http://java.sun.com/developer/Quizzes/jbasics1-1/

No comments: