Assignment 2: Creating Classes

Objective: Create Basic Java classes.

Due: Before the next class on Monday, Sep 15.

Set Up

Create a directory for assign2 within your cs209 directory.

Part 1: Fixing A Program

Save Assign2.java into your assign2 directory.

This program contains at least 5 errors. Some are compiler errors that the compiler will catch. Others are logic errors that you need to catch. One is an "access modifier" error that isn't good OO style.

Comment out the original code and note the cause of the error. Then, correct the code.

After you're sure the program behaves correctly, save the output in a file called debugged.out.

Part 2: Creating a Birthday Class

Create a Birthday (but not birth date) class. The state of the class should be the month and day. The methods of the class should be getting and setting the month and date. The constructor for the Birthday class should take as parameters the month and date.

The main method for the class should test your Birthday class. Don't just rerun the program a bunch of times, changing the code and recompiling and running. Have all the tester code in this method.

Pay close attention to the access modifiers you use for the state and methods.

I know, this doesn't seem like one of my normal problems.... We're building to something.

Save the output of your program in birthday.out

Turning in Your Assignment

As usual, copy your assign2 directory into your turnin directory, i.e., /home/courses/cs209/turnin/yourusername.

There is no printed part of this assignment.

Grading (80 pts)

You will be evaluated based on