Assignment 1
Due Date : 1/30 @ 11:59pm
Instructions
Each of you should have a repository in CCIS's GitHub with the name
assignment1-ccisLogin
. Use this repository
and add all your work there. In order to clone the repositories
from CCIS GitHub to your machine (or watch this video video instructions):
-
Sign in to GitHub.
-
On your CCIS GitHub home page your Github Handle should appear on the left as a button/drop down menu. Click that button and from the drop down menu select
cs8674sp15-seattle
. The CCIS GitHub page will then navigate to the class' web page and to the contents that is available to you. -
On the right you should be able to see all repositories to which you have been given access. Find the repository whose name matches the pattern
assignment1-ccisLogin
, where ccisLogin is your CCIS login name, e.g,assignment1-john123
, and click on it. -
On the repositories home page look at the bottom right hand corner for a button with the text Clone in Desktop. By clicking on this button your browser will launch the GitHub client that we installed in Lab1 and ask for a location on your drive to store the repository.
If you are not using the GitHub client the clone URL is located above the Clone in Desktop button. Copy the URL and issue the following command on your shell
git clone URL
. - Create a file and save it under the folder on your drive that you selected in the preceding step.
Remember to push your changes to the CCIS GitHub repository often.
Assignment Rules
-
You are not allowed to use any JDK APIs other than
java.lang
. - For any Java class that contains methods you are expected to provide tests using JUnit.
- For any Java class you are expected to provide valid Javadoc documentation. This means that running Javadoc on your your source code should successfully compile and generate documentation in HTML.
- For any images, e.g., for Class Diagrams, you are expected to provide a PDF version of the image.
Problem 1
All Java source code that is part of your solution to this problem must reside inside a java package with the name
edu.neu.ccs.cs8674.sp15.seattle.assignment1.problem1
A friend is trying to create a program to keep track of their library of books. He has started designing the program and after a first iteration your friend has create the following UML class diagram.
Your friend asked you to create the code based on his Class Diagram. Also your friend has asked to implement the following
- Book
-
implement the
toString()
method forBook
and provided the following as an example: for the book "The Unbearable Lightness of Being", written by Milan Kundera published in 1984 with ISBN 9780061148521, it should output"The Unbearable Lightness of Being", Milan Kundera (1984), ISBN:978-0061148521
-
implement the
equals()
andhashCode()
methods such that two Books are considered the same if and only if they have the sametitle
,author
,year
andISBN
. Ensure that your implementation satisfies the contracts for both methods equals(Object): boolean and hashCode(): int
-
implement the
- Author
- implement the
toString()
method forAuthor
so that it returns in order thefirst
,middle
andsecond
name separated by spaces. In the case that an author does not have a middle name return a string composed of thefirst
andsecond
name separated by one space. -
implement the
equals()
andhashCode()
methods such that twoAuthor
s are considered the same if and only if they have the samefirst
,middle
andsecond
names. Ensure that your implementation satisfies the contracts for both methods equals(Object): boolean and hashCode(): int
- implement the
-
Isbn
-
implement the
toString()
method forIsbn
so that it returns in order theprefix
followed by a hyphen, followed bygroup
,publicationElement
,registrationElement
andcheckDigit
. -
implement the
equals()
andhashCode()
methods such that twoIsbn
s are considered the same if and only if they have the sameprefix
,group
,publicationElement
,registrationElement
, andcheckDigit
. Ensure that your implementation satisfies the contracts for both methods equals(Object): boolean and hashCode(): int
-
implement the
-
Year
-
implement the
toString()
method forYear
so that it returns a string representation of the valueval
inside Year. -
implement the
equals()
andhashCode()
methods such that twoYear
s are considered the same if and only if they have the sameInteger
value. Ensure that your implementation satisfies the contracts for both methods equals(Object): boolean and hashCode(): int
-
implement the
-
Title
-
implement the
toString()
method forTitle
so that it returns a string representation of the valueval
inside Title. -
implement the
equals()
andhashCode()
methods such that twoTitle
s are considered the same if and only if they have the sameInteger
value. Ensure that your implementation satisfies the contracts for both methods equals(Object): boolean and hashCode(): int
-
implement the
Problem 2
All Java source code that is part of your solution to this problem must reside inside a java package with the name
edu.neu.ccs.cs8674.sp15.seattle.assignment1.problem2
You have been tasked to create the program to print boarding passes at airports. The boarding pass contains the following information
- The passenger's name. A boarding pass has one and only one passenger. The passenger has a first and last name and some might also have a middle name.
- The name of your destination. This is typically the name of a city.
- The name of your departure. This is typically the name of the city.
-
The time of departure. Time is hours and minutes only. The hours are
in 24 hour format; 0 to 23 where 0 is midnight and 23 is 11pm. Time should be displayed
with hours first, then a colon
:
and then minutes - The date of departure. This is the day, month and year, e.g., 01/22/2015. The example is also the way that the date appears on the boarding pass
- The gate from which you are departing. Gates have a composite name made up of a capital letter and a number, e.g., A87
- The passenger's boarding group. The boarding group is typically a number, e.g., 4.
- The airline with which the passenger is travelling, e.g., British Airways
- The flight number. The flight number is also a composed from two pieces of information, the airlines acronym and a number, e.g., BA8787
- Provide a UML Class Diagram of all classes that are part of your design. (For diagramming tools see UML Resources)
-
Provide Java code for your design. For each class that you create ensure that
you have appropriate implementation of
toString()
,equals()
andhashCode()