CS 201 - Lab 3

Post Office

In this lab you will use a set of JUnit test cases to figure out how to implement several classes.

Getting started

Import lab3.zip.  (File->Import...->General->Existing Projects into Workspace->Archive File).  You should see a project called lab3 in the Package Explorer.

Your Task

Your task is to implement the Address, Letter, and Mailbox classes by adding fields and methods.

You are done when the three JUnit test classes, AddressTest, LetterTest, and MailboxTest successfully pass all tests.

How do you know what fields and methods to add?  Look at the JUnit tests and figure out what behavior is expected of Address, Letter, and Mailbox objects.  Then modify those classes to match the expected behavior.  For example:

The constructor for the Address class takes 5 parameters: an int number, a String street name, a String city name, a String state, and an int zip code.  The getNumber method should return the same number passed as the first parameter to the Address constructor.

In general, a good set of tests provides a lot of information about how the classes being tested are supposed to work.


You should implement the Address class first, then the Letter class, and finally the Mailbox class.