Assessment 1

Introduction

ITCentre Library Application

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.

User Guide

Following classes are implemented in this library application.

  • Manual: This class holds the basic attributes of a manual.
  • Library: This class holds a list of all manuals.
  • ITCentreLibraryApplication: This is the main class to launch the application and display a menu to select different options.

How to run the program:

To run the program, compile all classes and run the main application class. i.e ITCentreLibraryApplication. This class will display following menu options.

  • Add a Manual
  • Display all Manuals
  • Search a Manual

Select the appropriate option and it will perform necessary action.

Technical Explanation of classes

Manual Class

It contains following data members or variables.

  • serial number
  • title
  • author

It has a constructor and a method to print details of all manual.

The following additional methods are included in this class

  • methods to set and get the properties of a Manual
  • a method to ask the user for details of a Manual
  • a toString() method.

Library Class

It contains details of all the manuals in the library. It has following methods.

  • Add a manual
  • Print details of all manuals

ITCentreLibraryApplication Class

This class contains the following methods.

  • add a manual to the library
  • display details of all manuals in the library
  • display details of a manual with a given serial number

Classes Listing

Manual Class

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;
}
}

Library Class

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Library {

List manualList = 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();
}
}
}
}

ITCentreLibraryApplication Class

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
}
}
}

Testing

TestManual Class

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());
}
}

Class Diagrams

Manual class diagram

See image.

Library Class Diagram

See image.

Assessment 2

ITCentre Library Application – additional features.

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:

  • that the manual is available, or has been lent out
  • the name of the member of staff who has borrowed the manual

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

  • display all manuals on loan
  • display all manuals not on loan
  • borrow a manual
  • return a manual.

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.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.