Skip to main content.

Assignment 2: Creating Classes

Objective: Create Basic Java classes.

Due: Before the next class (Monday).

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 is not 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.

There will be one constructor for the Birthday class. The constructor will take as parameters the month and date.

The methods of the class should be getting and setting the month and date.

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

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

This problem is "underspecified", e.g., I'm not saying how to represent the month and day. I'm leaving that up to you.

This problem should be as simple as it seems (no input, no application). Focus on writing good, solid, well-tested code.

The problem doesn't seem like one of my normal problems because it isn't. 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, e.g., turnin.sh assign2.

There is no printed part of this assignment.

Grading (100 pts)

You will be evaluated based on