REVIEW OF MATERIAL TO HELP PREPARE YOU FOR ASSIGNMENT DUE THURSDAY MARCH 31:

As we discussed in class today, here is an implementation of an object class that represents a month of the year:

public class Month
{
   int index;
   String name;

   public Month(int index, String name) {
      this.index = index;
      this.name = name;
   }
   public int index() { return index; }
   public String name() { return name; }
}
We can create an array of 12 month objects as follows:
   String names[] = {"January","February","March","April","May","June","July",
                     "August","September","October","November","December"};

   Month months[] = new Month[names.length];

   for (int i = 0 ; i < months.length ; i++)
      months[i] = new Month(i, names[i]);
We can display a table of these months within a Java applet's render method as follows:
   g.setColor(Color.black);
   for (int i = 0 ; i < months.length ; i++) {
      g.drawString("" + i          , 100, 100 + 30 * i);
      g.drawString(months[i].name(), 200, 100 + 30 * i);
   }

ASSIGNMENT DUE THURSDAY MARCH 31:

The assignment for this week is to help you practice creating and instantiating object classes, and to practice working with arrays of the objects you make.

The code above will help you with the concepts, but it won't do you any good to just literally copy the code above. In order to do this week's assignment, you will need to understand and apply the principles that are illustrated in the code above.

Your assignment, due before class next Thursday (March 31), is to write a program that can help you organize a list of things you'd like to get for your friends on their birthdays.

For this assignment, you need to use comments within the code to describe very clearly, in your own words, what each part of your program is doing. NOTE: This is very important. Part of your grade will depend on how clearly your comments describe what you are doing.

The assignment consists of three parts:

PART ONE:

Create a Java class call Friend, with the following constructor:

   // Constructor takes my friend's name,
   // and the month (1 through 12),
   // and the day (1 through 31) of their birthday.

   public Friend(String name, int month, int day) {
      ...
   }
which implements the following methods:
   public String getName()            // Returns: My friend's name.
   public int    getMonth()           // Returns: The month of my friend's birthday.
   public int    getDay()             // Returns: the day of the month of my friend's birthday.
   public void   setGift(String gift) // Specify a gift this friend would like.
   public String getGift()            // Returns: What gift I said this friend would like.

PART TWO:

Create an array of Friend objects, to remind you about the birthdays of at least three different friends. Each Friend object should contain information about that friend's name, the month and day of their birthday, and a text String describing their favorite gift.

If you don't have three friends, it's ok to use imaginary friends (although that would be kind of sad).

PART THREE:

Implement a Java applet that lists these friends, together with the month and day of each friend's birthday, and each friend's favorite gift. You should use the drawString method for this. The layout of your list on the screen should look something like this:

   Dumbledore            12   4        wand
   Gandalf               2    19       new hat
   Merlin                6    12       crystal ball
   Obi-wan Kenobe        3    27       lightsaber

Things you can do for extra credit: