Reference no: EM132671373
FIT9131 Programming foundations in Java - Monash University
Introduction
You must attribute the source of any part of your code which you have not written yourself. Your program will be checked with a code similarity detector. Please note the section on plagiarism in this document.
The assignment must be done using the BlueJ environment.
All user input to the system, and system output to the user, must be done at the BlueJ terminal window. No other graphical interfaces are to be used (nor assessed) in your program.
Specification
For this assignment you are required to write a program, My Library, that simulates a very small virtual library of electronic books. This section specifies the required functionality of this program.
Only a simple text interface (using the BlueJ Terminal Window) is required for this program; however, more marks will be gained for a game that is easy to follow with clear information/error messages to the player.
This program is functionally very different from the program you wrote in Assignment 1 and 2.
My Library should provide the following features:
• maintains a list (using a Java Collection class) of Borrower objects
o each Borrower object represents a person who can "borrow" books from the virtual library
o the list does not have a fixed size
• maintains a list (using a Java Collection class) of Book objects
o each Book represents a book which can be borrowed by a Borrower object
o each virtual book can be borrowed by different borrowers at the same time
o the list does not have a fixed size
o a book has a rating (General/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/she 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
o a sample data file will be provided to you - your program must be able to read the data from this file, and write back to the same file
• loads a list of books from a text file
o 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 classes to represent the various objects in the program
• 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
There will be a description of the Borrower and Book classes (and the collection classes which store them) 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 2 text files:
• "borrowers.txt" which contains details of all borrowers currently stored in the system
• "books.txt" which contains details of all books currently available in the system
The actual format of these text files 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 borrowers' data back to the same text file (borrowers.txt) - the book data does not need to be saved as it is not modified by this program.
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 these options,
Option (1) registers a new borrower. Information to be entered will be a name, an ID, and an age.
Option (2) manages an existing borrower. The borrower is to be searched for by some sensible criteria. A
second menu will allow the following operations for that borrower,
Note that a book's rating determines whether or not it can be borrowed by a particular borrower.
Option (3) lists all the current borrowers (& their borrowed books).
Option (4) displays some sensible help screen to explain how the program works.
Option (5) exits the program. All the borrowers' data currently in memory are automatically saved to "borrowers.txt". The memory is then cleared.
Inputs other than 1-5 (including non-numeric inputs) should be rejected, and an error message printed. The menu should be displayed repeatedly, until the user chooses Option (5).
Program Design
Your program must demonstrate your understanding of the object-oriented concepts and general programming constructs presented in FIT9131. Consider carefully your choice of classes, how they interact and the fields and methods of each class.
You must use appropriate data structures to store the various objects (list of borrowers, list of books, etc) in the program. If you do not understand what this means, ask your tutor now.
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 (ie. put some simple validations in your mutator methods).
Discuss with your tutor what classes are appropriate, and how they interact with each other. The main requirements are:
(1) the borrowers and books must be implemented as objects, and they must be stored in some appropriate Java collections (e.g. an ArrayList of Borrowers)
(2) the list of books within each borrower object must also be stored in some appropriate Java collections (e.g. an Array of 2 Books)
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.
Exception handling should be used where appropriate.
All on-screen input/output should be formatted in a user-friendly manner. Sensible error messages should be displayed whenever appropriate (e.g. entering a duplicate borrower ID, entering a number outside the allowable valid range, etc).
Attachment:- Programming foundations in Java.rar