Professional Documents
Culture Documents
In this project, we will solidify our class making abilities. Specifically, we will create multiple
classes, use files to store and retrieve data, write JavaDoc documentation, and test our code
with JUnit tests. To begin, create a project in Eclipse named Project1. Now, create multiple
classes that follow the requirements for each class listed below.
Class Address:
Create a class named Address that has the following private Instance Properties:
● int streetNum - An integer variable that holds the street number of the address.
This value cannot be negative
● String streetName - A String object that holds the street name
● String city - A String object that holds the name of the city
● String state - A String object that holds the two-letter abbreviation of the state
● String zipCode - A String object that holds the five-digit ZIP code
Class Bicycle:
Create a class named Bicycle that has the following private Instance Properties:
● int bicycleId - An integer variable that holds the ID of the account. This ID is auto
generated and starts from 500. The very first bicycle object will have an ID of 500. Each
bicycle object after will get an ID incremented by 5. For example, the 2nd and 3rd
bicycle objects are going to have an ID of 505 and 510, respectively.
● String brand - A String object that holds the name of the company that built the bike
● String color - A String object that holds the color of the bike
● double miles - A double value that holds the number of miles the bike has traveled
● BikeOwner owner - A BikeOwner object that holds the information for the owner of
the bike
Class BikeOwner:
Create a class named BikeOwner that has the following private Instance Properties:
● String name - A String object that holds the name of the bike owner
● Address address - An Address object that holds the address of the bike owner
● Bicycle bike - A Bike object that holds the information about the bike this bike
owner has
● boolean wearsHelmet - A boolean value that returns true if the bike owner wears
a helmet when they ride their bike, and false otherwise
In each tester class, you have to test all the methods of the classes including constructors,
getters and setters (that include logic in the method), and the remaining public interface
methods. You can create multiple objects of the class for testing purposes. When you test, you
need to make sure you think about all possible scenarios (edge cases) for each individual
method. See the corresponding Lecture Code for examples.
Now, when you are going to write your JUnit tests for the Bicycle class, you will be able to
directly access these static variables. One important thing to remember is that static variables
retain their values between JUnit test cases. So, you must manually reset the static variables for
each test method by doing the following:
Bicycle.staticID = 500;
Important Note:
For validation checking, you must check the following instance parameters:
● Address
○ streetNumber - it cannot be negative
○ state - valid length of two and made up of alphabetical characters
○ zipCode - valid length of 5 (we don’t care about 9 number long zip codes) and
made up of numeric characters
● Bicycle
○ miles - it cannot be negative
If any of the previous instance parameters are invalid, you should throw an
IllegalArgumentException (Hint: In order to manually throw an Exception, you’ll have to use the
throw keyword)
Submission Instructions:
Submit your .java files (Address.java, Bicycle.java, BikeOwner.java, AddressTester.java,
BicycleTester.java, and BikeOwnerTester.java) to the corresponding Project 1 assignment’s
CODE plugin.
Rubric:
Task Grade
Address
Correctly implement constructors 8
Correctly implement getters and setters 6
Correctly implement equals() method 4
Correctly implement toString() method 4
Bicycle
Correctly implement constructors 8
Correctly implement getters and setters 6
Correctly implement equals() method 4
Correctly implement toString() method 4
BikeOwner
Correctly implement constructors 8
Correctly implement getters and setters 6
Correctly implement toString() method 4
Correctly implement both rideBike() methods 6
Correctly implement chancesOfCrashing() method 4
Tester Classes
Test constructors 9
Test getters and setters with validation logic 8
Test equals() and toString() methods 5
Test rideBike() and chancesOfCrashing() methods 6
JavaDoc and Intermediate Submission
Total 100