Specification
For this request you are required to write a program, My Library, that simulates a very small library of electronic books. This section specifies the required functionality of this program.
Even though this program is functionally very different from the program you wrote in request 1, you should be able to re-use much of your previous code here - if you have designed the classes/logic in your previous program properly. This is one of the major benefits of an object-oriented program - the ability to re-use classes.
My Library should provide the following features:
- maintains a list (using a Java Collection class) of Borrower objects
each Borrower object represents a person who is allowed to borrow some books from the library - maintains a fixed list of exactly 10 books
- each book is implemented using a String, which consists of the book’s title and the author
- each book can be borrowed by different borrowers at the same time
- (HD level) maintains a fixed list of unlimited Book objects
- each Book object represents a single (electronic) book which can be borrowed by different borrowers at the same time
- a book has a rating (children/adult), which limits its availability to a borrower based on his age
- allows each borrower to borrow up to 2 books at any one time
- lists the details of an existing borrower and the books he has currently borrowed
- produces a report of all borrowers
- allows a borrower to borrow/return a book
- loads a list of borrowers from a text file
- a sample data file will be provided to you – your program must be able to read the data from this file
- (HD level) loads a list of books from a text file
- a sample data file will be provided to you – your program must be able to read the data from this file
- saves the list of current borrowers (with the borrowed books) to a text file
You are to demonstrate the following programming techniques in your program:
- reading/writing data from/to text files
- using appropriate Java Collection class or classes to store data
- using code to manipulate the data in the collection(s)
- performing simple searches, filtered by some given criteria
- using program constructs such as repetitions & selections
- using appropriate classes to represent the various objects in the program
There will be a description of the “HD level” features later in this document.
You are also required to produce a partial Test Strategy for your program.
Program Logic
When the program starts, it should automatically load a text file called “borrowers.txt” which contains details of all borrowers currently stored in the system. The actual format of this text file is described later in this document. The data loaded should be stored in some appropriate data structures. No other reading from (or writing to) file is required while the program is in operation, until the user chooses to exit, at which point the program saves all the in-memory data back to the same text file (borrowers.txt).
In other words, all the file I/O operations are performed automatically by the program, once at the start and once at the end, and require no interactions with the user.
When the program is running, it should repeatedly display a menu with at these options (non-HD level), such as:1
2
3
4
5
6
7
8Welcome to the My Library
====================
(1) Register New Borrower
(2) Manage Borrower
(3) List All Borrowers
(4) Display Help
(5) Exit Library
Choose an option:
Program Design
Your program must demonstrate your understanding of the object-oriented concepts and general programming constructs presented in FIT9131. You must use appropriate data structures to store the various objects (list of borrowers, list of books (HD-level), etc) in the program.
You must be able to justify the choice of the data structures during your interview. You must document any additional assumptions you made.
Appropriate validations of values for fields and local variables should also be implemented. You should not allow an object of a class to be initialized/set to an invalid state.
Discuss with your tutor what classes are appropriate, and how they interact with each other. The main requirements are: (1) the borrowers (and for the HD level, the books) must be implemented as objects, and they must be stored in some appropriate Java collections, and (2) the list of books within each borrower object must also be stored in some appropriate Java collections.
Your program must deal with invalid values entered by the user in a sensible manner. For instance, if a user enters “abc” when a number is expected, your program should not crash.
All on-screen input/output should be formatted in a user-friendly manner. Sensible error messages should be displayed whenever appropriate (eg. entering a duplicate borrower ID, entering a number outside the allowable valid range, etc).
Test Strategy
For this request, you are required to produce and submit a partial Test Strategy for the program.
Your Test Strategy will be only for one class - the Borrower class.
There is no need to produce Test Strategy for any other classes you have used in your program.
You must provide a Test Plan, plus detailed sets of Test Data, Expected Results and Actual Results for the Borrower class.