Introduction

This assignment is worth 20% of the marks for your final assessment in this unit. Heavy penalties will apply for late submission. This is an individual assignment and must be entirely your own work. 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.

The Java source code for this assignment must be implemented according to the FIT9131 Java Coding Standards.

Any points needing clarification should be discussed with your tutor in the tutorial session. You should not make any assumptions about the program without consulting with your tutor. 

Learning outcomes

1) Design, construct, test and document small computer programs using Java.
2) Interpret and demonstrate software engineering principles of maintainability, readability, and modularisation.
3) Explain and apply the concepts of the "object-oriented" style of programming.

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.

Even though this program is functionally very different from the program you wrote in Assignment 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. 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
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, such as:

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, such as:
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).
Welcome to the My Library
====================
(1) Register New Borrower
(2) Manage Borrower
(3) List All Borrowers
(4) Display Help
(5) Exit Library
Choose an option:
Select an option:
=================
(1) Borrow a Book
(2) Return a Book
(3) List Borrowed Books
(4) Return to Main Menu
Choose an option:
Main menu
Menu for
managing
borrower

Additional Notes :

The menu must be displayed repeatedly after each menu operation, until the user chooses Option (5).

If the user chooses Options (2) in the main menu, he should be shown a list of current borrowers in the system, and asked to choose the one he wishes to manage.

Your program must deal in a sensible way with invalid values entered by the user.
For all the options, the inputs/outputs can be formatted in many different ways. Discuss with your tutor regarding how you should implement these in your program.

Your user interface need not be exactly as shown in the examples shown above. However, you should discuss with your tutor about what to include in your user interface. Keep it simple.

Important: see the Program Design section below for a description of what classes you need to implement in your program. Failure to implement those required classes will cause loss of marks.

There will be some hints in the forum on Moodle later regarding how you should develop the program for this assignment. Make sure you check them out when they are available.

Important Requirements

You must satisfy the following requirements when implementing your program:
a Borrower object remembers the following data:
o name: a String
must not be blank, must be alphabetic, must not contain commas
should be unique
o ID: an int
must be unique, and between 1-100 (inclusive)
o age: an int
must be > 5 and < 110
o booklist: a list of Book objects
a Book object remembers the following data:
o title: a non-empty String, must not contain commas
o author: a non-empty String, must not contain commas
o rating: a non-empty String (valid values are “General” or “Adult”)
only borrowers who are more than 18 years old are allowed to borrow books with an “Adult” rating.
you must use appropriate Java data structures to store the Borrower and Book objects in your program – see the Program Design section for more details.
you may assume that the input data files are always in the correct formats (see below) - ie. no need to validate the data when reading them in.
all operations must be applied to the in-memory data, or data structures - there must not be constant reading/writing to/from the data file, except once at the start (when the program loads all data from the file) and once at the end (when the program saves all data back to the file, when it exits)
the program must not crash when accepting user inputs, regardless of what the user enters.

Input File Formats

The first input data file (borrowers.txt) has the following format for each linename,ID,age,title1,author1,rating1,title2,author2,rating2
E.g. the following sample data file contains 3 borrowers:
David Smith,1,19,Book of Java,John Wilson,General,ABC of Life,Arnold S,Adult
John Li,2,22,ABC of Life,Arnold S,Adult,Network Security,Jeremy Hacker,Adult
Sue Dally,3,55,How to use a Computer,David Noidea,General
Each line represents a single “borrower”. The fields are separated by commas. Each “book” takes up 3
fields. Note that the colouring shown above are for illustration only.
The second input data file (
books.txt) has the following format for each line:
title,author,rating
E.g. the following sample data file contains 3 books:
ABC of Life,Arnold S,Adult
Network Security,Jeremy Hacker,Adult
How to use a Computer,David Noidea,General
Each line represents a single “book”. The fields are separated by commas. Each “book” takes up 3 fields.
Note that the colouring shown above are for illustration only.
You may assume:
• the strings which represent the Borrower/Book fields (name/title/author/etc) do not contains commas (ie. a name like "Andrew, Smith" will not be possible).
• this program does not provide the functionality to edit the book list (ie. use a text editor to edit "books.txt" if you wish to modify the book list).
• this program does not provide the functionality to edit/remove a borrower once registered (ie. use a text editor to edit "borrowers.txt" if you wish to modify the borrower list).

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).

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).
Note: The description of the program’s logic/design is purposely left vague, to give you some room to exercise your own design and creativity. Discuss with your tutor about what/how to implement.
Your program must consist of at least these classes:
MyLibrary – main class, which contains the program's main logic
Borrower – represents a single borrower
Book – represents a single book
BorrowerDatabase – represents a list of borrowers
BookDatabase – represents a list of books
any other appropriate classes (e.g. a Menu class) as discussed with your own tutor

Test Strategy

For this assignment, you are required to produce and submit a partial Test Strategy for the program.

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 Book class.

Assessment for this assignment will be done via an interview with your tutor. The marks will be allocated as follows:
10% - Test Strategy for the Book class.
35% - Java Code & Object-Oriented design quality. This will be assessed on appropriate implementation of classes, fields, constructors, methods, and validations of the objects' states.

55% - Program Functionality in accordance with the requirements.

You must submit your work by the submission deadline on the due date (a late penalty of 20% per day, inclusive of weekends, of the possible marks will apply - up to a maximum of 100%).  There will be no extensions - so start working on it early.

Marks will be deducted for incomplete/untidy submissions, and non-conformances to the FIT9131 Java Coding Standards.

All submitted source code must compile. Any submission that does not compile, as submitted, will receive a grade of ‘N’.

Interview

You will be asked to demonstrate your program at an "interview" following the submission date. At the interview you can also expect to be asked to explain your code/design, modify your code, and discuss your design decisions and alternatives. Marks will not be awarded for any section of code or functionality that  student cannot explain satisfactorily (the marker may also delete excessive in-code comments before you are

asked to explain that code).

In other words, you will be assessed on your understanding of the code, and not on the actual code itself.

The interviews will be organised during week 12 and will take place online via Zoom or other video facility after that time.

 You must have audio and video available and operating during the interview. It is your responsibility to make yourself available for an interview time and ensure that you have the audio and video capabilities. Any student who does not attend an interview will receive a mark of 0 for the assignment.

Your Test Strategy will be only for one class - the Book class.

Submission Requirements

The assignment must be uploaded to Moodle on or before the due date. The link to upload the assignment will be made available in the Assignments section of the unit’s Moodle site before the submission deadline.

The submission requirements are as follows:

A .zip file uploaded to Moodle containing the following components:
the BlueJ project you created to implement your assignment. The .zip should be named with your Student ID Number. For example, if your id is 12345678, then the file should be named 12345678_A2.zip. Do not name your file any other way.
it is your responsibility to check that your ZIP file contains all the correct files, and is not corrupted, before you submit it. If you tutor cannot open your zip file, or if it does not contain the correct files,
you will not be assessed.
an MS Word document containing your Test Strategy for the Book class. (Note: The JUnit facility in BlueJ is NOT to be used for this assignment)

there is no need to submit a physical Assignment Cover Sheet – you will be asked to accept an online submission statement when you submit the assignment

Marks will be deducted for failure to comply with any of these requirements.

Warning: there will be no extensions to the due date. Any late submission will incur the 20% per day penalty. It is strongly suggested that you submit the assignment well before the deadline, in case there are some unexpected complications on the day (e.g. interruptions to your home internet connection).

Plagiarism

Cheating and plagiarism are viewed as serious offences. In cases where cheating has been confirmed, students have been severely penalised, from losing all marks for an assignment, to facing disciplinary actio at the Faculty level. Monash has several policies in relation to these offences and it is your responsibility to acquaint yourself with these.
Monash Plagiarism Policy: (
https://www.monash.edu/students/admin/policies/academic-integrity).