COP3804 Spring, 2015 Assignment #1 – Library System phase I

advertisement
COP3804
Spring, 2015
Assignment #1 – Library System phase I
Last updated 02/09/2015 05:40 pm
This program represents a simple library system, which could hypothetically be used by a library to
maintain information on their items, members, requests, etc.
The system will be developed in several phases. This document describes the functionality to be
implemented for phase I, due February 14th.
The library’s staff members would be using the system; from now on we will refer to these people
as the “user”.
For phase I, we are just going to implement several classes, but we are not going to implement a
user interface. I am providing you with code for the LibrarySystem_Phase1 class, which is the class
that has the main method.
Important: All the classes that you implement are to provide a constructor with enough parameters
to initialize all instance variables (all classes also have a copy constructor, except for the Library
class). Additionally, all classes need to provide a getter and a setter method for all instance
variables, as well as the toString, equals, and copy methods. (Do not provide a copy method for the
Item or Book classes).
The toString method in each class returns a String with the value of all the instance variables
including labels.
The equals method compares two objects of the same type: the calling object and the one passed as
an argument. It has one parameter whose data type is Object and it returns true if the argument is
an object of the same type, is not null, and has the same value for all fields as the calling object.
Otherwise, it returns false.
The copy method returns a new object of the same class where every field has the same value as the
calling object.
Member – This class represents a member of the library.
Private Instance Variables:
memberID of type int
firstName of type String
lastName of type String
phone of type String
listOfRequests of type ArrayList<Request>
Public Instance Methods:
addRequest – This method doesn’t return a value and it has 1 parameter of type Request. It adds a
copy of the Request parameter to the listOfRequests instance variable.
Notes:

Exclude the memberId and listOfRequests fields from the comparison in the equals method.
Item – This class represents an item from the library that a member can check out or download.
This is an abstract class.
Private Instance Variables:
itemID of type int
title of type String
genre of type String
targetAudience of type String
available of type boolean
Notes:


Exclude the itemId and available fields from the comparison in the equals method.
This class does not have a copy method.
Book – This is an abstract class that extends the Item class. It represents a book that a member can
check out or download.
Private Instance Variables:
author of type String
isbn of type String
Notes:

This class does not have a copy method.
PrintedBook – This class extends the Book class and implements the CanBeCheckedOut interface.
It represents printed books.
Private Instance Variables:
coverType of type String
Public Static Constant:
DAILY_RATE of type double – initialize to 1.50 in the declaration.
Public Instance Methods:
calculateFee – this method overrides the implementation in the CanBeCheckedOut interface, which
doesn’t have a body, while this one provides the calculation. The value that this method returns is
the value of the DAILY_RATE constant multiplied by the number of days parameter.
calculateFine – this method overrides the implementation in the CanBeCheckedOut interface, which
doesn’t have a body, while this one provides the calculation. The value that this method returns is
the value of the DAILY_RATE constant multiplied by the number of days parameter multiplied by
0.25. In order words, a fine would be a quarter of the regular rate.
ElectronicBook – This class extends the Book class and implements the CanBeDownloaded
interface. It represents downloadable electronic books.
Private Instance Variables:
fileType of type String
Public Static Constant:
FLAT_FEE of type double – initialize to 9.99 in the declaration.
Public Instance Methods:
calculateFee – this method overrides the implementation in the CanBeDownloaded interface. It
returns the value of the FLAT_FEE constant.
AudioBook – This class extends the Book class and it implements the CanBeDownloaded interface.
It represents downloadable audio books.
Private Instance Variables:
duration of type double
extraCharge of type double
Public Static Constant:
FLAT_FEE of type double – initialize to 12.99 in the declaration.
Public Instance Methods:
calculateFee – this method overrides the implementation in the CanBeDownloaded interface. It
returns the value of the FLAT_FEE constant plus the value of the extraCharge field
DVD – This class extends the Item class and implements the CanBeCheckedOut interface. It
represents a DVD that a member can checkout.
Private Instance Variables:
videoNumber of type String
duration of type double
closedCaptions of type boolean
calculateFee – this method overrides the implementation in the CanBeCheckedOut interface. The
value that this method returns is the value of the DAILY_RATE constant multiplied by the number of
days parameter.
calculateFine – this method overrides the implementation in the CanBeCheckedOut interface. The
value that this method returns is the value of the DAILY_RATE constant multiplied by the number of
days parameter multiplied by 2. In order words, a fine would be double the regular rate.
Request – This class represents a request a member makes to checkout an item.
Private Instance Variables:
memberID of type int
itemID of type int
requestDate of type String
dueDate of type String
status of type String
Library – This class represents the library that is using this software.
Private Instance Variables:
libraryName of type String
memberList of type ArrayList<Member>
itemList of type ArrayList<Item>
requestList of type ArrayList<Request>
Public Instance Methods:
addMember – This method doesn’t return a value and it has 1 parameter of type Member. It adds the
parameter to the memberList instance variable.
addItem – This method doesn’t return a value and it has 1 parameter of type Item. It adds the
parameter to the itemList instance variable.
addRequest – This method doesn’t return a value and it has 1 parameter of type Request. It adds the
parameter to the requestList instance variable.
The following is the code for the CanBeCheckedOut interface:
public interface CanBeCheckedOut
{
double calculateFee(int numDays);
double calculateFine(int numDays);
}
The following is the code for the CanBeDownloaded interface:
public interface CanBeDownloaded
{
double calculateFee();
}
Group Member Responsibilities:
Group Member 1
Group Member 2
Group Member 3
Group Member 4
Implementation of the Item and ElectronicBook classes.
Implementation of the Member and AudioBook classes.
Implementation of the Request and Book classes.
Implementation of the DVD and PrintedBook classes.
Download