Assignment 4: Intro to Object-Oriented Programming in Java
Objective: Creating and debugging basic Java class.
Due: Before the next class (Monday).
Set Up
Cloning the Repository
In your terminal, go to the directory where you are keeping your repositories for CSCI209. Clone the repository for this assignment. Add your name to the README file.
Part 1: Fixing A Program (40)
Assign4.java
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
. Add the file to
your repository.
Part 2: Creating a Birthday Class (40)
Create a Birthday
(but not birth date) class.
The state of the class should be the month
and day
. You will write this class from scratch, so
remember to add it to your repository.
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. See the Chicken
class as an
example.
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, no error handling). Focus on writing good, solid, well-commented (JavaDocs!), and 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
Add
that file to your repository.
Submission
As usual, put all of your code and output files in your GitHub repository that both you and I can access.
Grading (90 pts)
You will be evaluated based on
- (40 pts) Part 1: Catch, fix, explain all errors
- (40 pts) Part 2: Correctness of your program (e.g., no compiler or runtime errors, matches specification)
- (10 pts) Parts 1--2: Proper style, indentation, documentation of Java programs