The IT Centre of a small company maintains a small library of technical manuals. You have been given the task to design and implement a small application which will keep track of the library stock. The application is to be written in Java. Eventually, the application will be run with a Windows-type graphical user interface, but during the development stage all input/output will be via the console.
When a manual is received into stock it is allocated a serial number; each manual also has a title and an author.
Following classes are implemented in this library application.
To run the program, compile all classes and run the main application class. i.e ITCentreLibraryApplication. This class will display following menu options.
Select the appropriate option and it will perform necessary action.
It contains following data members or variables.
It has a constructor and a method to print details of all manual.
The following additional methods are included in this class
It contains details of all the manuals in the library. It has following methods.
This class contains the following methods.
import java.util.Scanner;
public class Manual {
private String serialNumber = "??????";
private String title = "Untitled";
private String author = "Unknown";
public Manual() {
}
public Manual(String serialNumber, String title, String author) {
this.serialNumber = serialNumber;
this.title = title;
this.author = author;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public void getManualDetails(){
Scanner scanner = new Scanner(System.in);
System.out.println("Eneter Serial Number:");
serialNumber = scanner.next();
System.out.println("Eneter Title:");
title = scanner.next();
System.out.println("Eneter Author:");
author = scanner.next();
}
public void print() {
System.out.println("Serial Number:" + serialNumber);
System.out.println("Title:" + title);
System.out.println("Author:" + author);
}
@Override
public String toString() {
return "Serial Number:" + serialNumber + "n"
+ "Title:" + title + "n"
+ "Author:" + author;
}
}
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Library {
ListmanualList = new ArrayList ();
public Library() {
}
public void addMaual() {
Scanner scanner = new Scanner(System.in);
System.out.println("Eneter Serial Number:");
String serialNumber = scanner.next();
System.out.println("Eneter Title:");
String title = scanner.next();
System.out.println("Eneter Author:");
String author = scanner.next();
Manual manual = new Manual(serialNumber, title, author);
manualList.add(manual);
}
public void displayAllManuals() {
Manual manual;
for (int i = 0; i < manualList.size(); i++) {
manual = manualList.get(i);
manual.print();
}
}
public void searchManual() {
Manual manual;
Scanner scanner = new Scanner(System.in);
System.out.println("Eneter Serial Number:");
String serialNumber = scanner.next();
for (int i = 0; i < manualList.size(); i++) {
manual = manualList.get(i);
if (manual.getSerialNumber().equalsIgnoreCase(serialNumber)) {
manual.print();
}
}
}
}
import java.util.Scanner;
public class ITCentreLibraryApplication {
public static void main(String[] args) {
int action = 0;
Scanner input = new Scanner(System.in);
Library library = new Library();
while (true) {
// create loop displaying main menu
// print menu
System.out.println("Main menun"
+ "1: Add Manualn"
+ "2: Display All Manualsn"
+ "3: Search Manualn"
+ "4: Exit");
System.out.println("Enter a choice: ");
// accept input
action = input.nextInt();
switch (action) {
case 1:
library.addMaual();
break;
case 2:
library.displayAllManuals();
break;
case 3:
library.searchManual();
break;
case 4:
// nothing to actually do here, just let it fall thru to the while condition
System.exit(1);
default:
System.out.println("Please enter a valid menu option");
break;
}// end switch
}
}
}
public class TestManual {
public TestManual() {
}
public static void main(String args[]){
Manual manual = new Manual("1", "Test Title", "Test Author");
manual.print();
manual.getManualDetails();
System.out.println(manual.toString());
}
}
Staff members may borrow a manual from the IT Centre library. Extend your Manual class to produce a LoanableManual class. When a manual is loaned to a staff member the borrower's name is recorded against the manual.
A LoanableManual should have additional properties indicating:
Design and implement appropriate methods for a LoanableManual and write a simple application to test your LoanableManual class. You should pay particular attention to the parameter(s) for your methods.
Develop a menu driven application that will enable the library to keep track of their manuals. A member of staff indicates which manual they wish to borrow. If a copy is available then the borrower's name is recorded against the manual. The staff member will return the manual when they have finished with it.
Your application should provide features which enable a user to
Add methods that will enable details of the manuals (with the borrower’s name) to be saved to a file and loaded back on a subsequent occasion.
The ITCentre library later decide to keep several copies of the more popular manuals; each copy will have the same serial number and the copies will be allocated ascending copy numbers. The first time a manual is added to the library it will be designated copy number 1; every subsequent copy will be assigned a value one more than the current highest copy number of that manual. Amend your application to assign copy numbers when adding manuals to the library.
Discuss the amendments that will be required to your loan and return methods when the library implements this system. You are not required to implement these methods; however you may find it helps your discussion if you do so.