Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help creating the menu for this program. I would like it to have a do-while so that way the user can do more

image text in transcribed

I need help creating the menu for this program. I would like it to have a do-while so that way the user can do more stuff. Like add books/ delete books,get books and add users. I would like the option to add an user to ask if youre a student of professor.

That it opens the 3 documents (student,books and registry) and then enters a do-while.

I already have this code below of the program but I need to add everything I wrote above. Help with the menu

1. LibraryInterface

package projectinterface;

import library.Book; import library.Faculty; import library.Student;

public interface LibraryInterface {

public void addBook(Book book);

public void addStudent(Student student);

public void addFaculty(Faculty faculty);

public void printBookInfo(String ISBN);

public void deleteBook(String ISBN);

public void deleteStudent(String ID);

public void deleteFaculty(String ID);

public boolean checkBookIsBorrowed(String ISBN);

public boolean checkStudentHasBooks(String ID);

public boolean checkFacultyHasBooks(String ID);

public void printAllBooks();

public void printAllBooksForPerson(String ID);

public void printAllBooksByDepartment(String department);

public void borrowBookToStudent(String ID, String ISBN);

public void borrowBookToFaculty(String ID, String ISBN);

public void returnBookFromStudent(String ID, String ISBN);

public void returnBookFromFaculty(String ID, String ISBN);

public void printBorrowedBookRegistry(); }

2. Library

package library;

import java.util.ArrayList;

import projectinterface.LibraryInterface;

public class Library implements LibraryInterface { private ArrayList studentList = new ArrayList(); private ArrayList facultyList = new ArrayList(); private ArrayList bookList = new ArrayList(); private ArrayList registryList = new ArrayList(); public ArrayList getStudentList() { return studentList; } public void setStudentList(ArrayList studentList) { this.studentList = studentList; } public ArrayList getFacultyList() { return facultyList; } public void setFacultyList(ArrayList facultyList) { this.facultyList = facultyList; } public ArrayList getBookList() { return bookList; } public void setBookList(ArrayList bookList) { this.bookList = bookList; } public ArrayList getRegistryList() { return registryList; } public void setRegistryList(ArrayList registryList) { this.registryList = registryList; } @Override public void addBook(Book book) { // TODO Auto-generated method stub this.bookList.add(book); } @Override public void addStudent(Student student) { // TODO Auto-generated method stub this.studentList.add(student); } @Override public void addFaculty(Faculty faculty) { // TODO Auto-generated method stub } @Override public void printBookInfo(String ISBN) { // TODO Auto-generated method stub for(int i = 0; i

}

3. Student

package library;

public class Student{ //first name, last name, ID, department and level (1, 2, 3 or 4) and amount of borrowed books public Student(String fName, String lName, String dept, String iD, String level, String amountBook) { super(); this.fName = fName; this.lName = lName; this.dept = dept; ID = iD; this.level = level; this.amountBook = amountBook; } private String fName; private String lName; private String dept; private String ID; private String level; private String amountBook; public String getfName() { return fName; } public void setfName(String fName) { this.fName = fName; } public String getlName() { return lName; } public void setlName(String lName) { this.lName = lName; } public String getDept() { return dept; } public void setDept(String dept) { this.dept = dept; } public String getID() { return ID; } public void setID(String iD) { ID = iD; } public String getLevel() { return level; } public void setLevel(String level) { this.level = level; } public String getAmountBook() { return amountBook; } public void setAmountBook(String amountBook) { this.amountBook = amountBook; } }

3. Faculty:

package library;

public class Faculty{ //first name, last name, department, ID and position (adjunct professor, assistant professor, professor) and amount of borrowed books private String fName; private String lName; private String dept; private String ID; private String position; private String amountBook; public String getfName() { return fName; } public void setfName(String fName) { this.fName = fName; } public String getlName() { return lName; } public void setlName(String lName) { this.lName = lName; } public String getDept() { return dept; } public void setDept(String dept) { this.dept = dept; } public String getID() { return ID; } public void setID(String iD) { ID = iD; } public String getPosition() { return position; } public void setPosition(String position) { this.position = position; } public String getAmountBook() { return amountBook; } public void setAmountBook(String amountBook) { this.amountBook = amountBook; }

}

5. Book:

package library;

public class Book { //title, author, ISBN number, number of pages, edition, publisher and engineering type (CPEN, ELEN, IMEN, MEEN or CIEN) public Book(String title, String iSBN, String pages, String edition, String publisher, String engType) { super(); this.title = title; ISBN = iSBN; this.pages = pages; this.edition = edition; this.publisher = publisher; this.engType = engType; } private String title; private String ISBN; private String pages; private String edition; private String publisher; private String engType; public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getISBN() { return ISBN; } public void setISBN(String iSBN) { ISBN = iSBN; } public String getPages() { return pages; } public void setPages(String pages) { this.pages = pages; } public String getEdition() { return edition; } public void setEdition(String edition) { this.edition = edition; } public String getPublisher() { return publisher; } public void setPublisher(String publisher) { this.publisher = publisher; } public String getEngType() { return engType; } public void setEngType(String engType) { this.engType = engType; } }

6. Registry:

package library;

import java.util.HashMap; import java.util.Map;

public class Registry { //borrowers ID and the ISBN number private String ID; private String ISBN; public String getID() { return ID; } public void setID(String iD) { ID = iD; } public String getISBN() { return ISBN; } public void setISBN(String iSBN) { ISBN = iSBN; } public Registry(String iD, String iSBN) { super(); ID = iD; ISBN = iSBN; } }

7. Driver:

package library;

import java.util.Scanner;

import projectinterface.LibraryInterface;

public class Driver {

public static void main(String[] args) { // TODO Auto-generated method stub

/* * Add a new book Add a new student Add a Faculty Search for information * about a specific book (use ISBN) Delete a book (use ISBN) Check first * if a user hasnt borrowed the book Delete a user from the system * Verify the user has returned all his books first Show all books Show * all books for a specific user (use ID) Show all books for a specific * department Borrow a book to a user Return a book Show every user and * the books borrowed by user */

LibraryInterface parentObject = new Library();

System.out.println("Please Chose: "); System.out.println("1. Add a new book"); System.out.println("2. Add a new student"); System.out.println("3. Search for information about a specific book (use ISBN)"); System.out.println("4. Delete a book (use ISBN)"); System.out.println("5. Check first if a user hasnt borrowed the book"); System.out.println("6. Delete a user from the system"); System.out.println("7. Verify the user has returned all his books first"); System.out.println("8. Show all books"); System.out.println("9. Show all books for a specific user (use ID)"); System.out.println("10. Show all books for a specific department"); System.out.println("11. Borrow a book to a user"); System.out.println("12. Return a book"); System.out.println("13. Show every user and the books borrowed by user"); System.out.println("14. Exit");

while (true) { Scanner sc = new Scanner(System.in); int choice = sc.nextInt();

switch (choice) { case 1: {

System.out.println( "Enter details: title, author, ISBN number, number of pages, edition, publisher and engineering type (CPEN, ELEN, IMEN, MEEN or CIEN)::::"); String title = sc.nextLine(); String ISBN = sc.nextLine(); String pages = sc.nextLine(); String edition = sc.nextLine(); String publisher = sc.nextLine(); String engType = sc.nextLine(); Book book = new Book(title, ISBN, pages, edition, publisher, engType); parentObject.addBook(book); System.out.println("DONE"); break; } case 2: { System.out.println("Enter details: first name, last name, ID, department and level (1, 2, 3 or 4) and amount of borrowed books::::"); String fName = sc.nextLine(); String lName = sc.nextLine(); String dept = sc.nextLine(); String ID = sc.nextLine(); String level = sc.nextLine(); String amountBook = sc.nextLine(); Student student = new Student(fName, lName, dept, ID, level, amountBook); parentObject.addStudent(student); System.out.println("DONE"); break; } case 3: { System.out.println("Enter ISBN number::::"); String ISBN = sc.nextLine(); ISBN = sc.nextLine(); parentObject.printBookInfo(ISBN); System.out.println("DONE"); break; } case 4:{ System.out.println("Enter ISBN number::::"); String ISBN = sc.nextLine(); ISBN = sc.nextLine(); parentObject.deleteBook(ISBN); System.out.println("DONE"); break; } case 5:{ System.out.println("Enter ISBN number::::"); String ISBN = sc.nextLine(); ISBN = sc.nextLine(); boolean check = parentObject.checkBookIsBorrowed(ISBN); System.out.println(check); System.out.println("DONE"); break; } case 6:{ System.out.println("Enter ID::::"); String ID = sc.nextLine(); ID = sc.nextLine(); parentObject.deleteStudent(ID); System.out.println("DONE"); break; } case 7:{ System.out.println("Enter ID::::"); String ID = sc.nextLine(); ID = sc.nextLine(); boolean check = parentObject.checkStudentHasBooks(ID); System.out.println(check); System.out.println("DONE"); break; } case 8:{ parentObject.printAllBooks(); System.out.println("DONE"); break; } case 9:{ System.out.println("Enter ID::::"); String ID = sc.nextLine(); ID = sc.nextLine(); parentObject.printAllBooksForPerson(ID); System.out.println("DONE"); break; } /*case 10:{ System.out.println("Enter Department::::"); String department = sc.nextLine(); parentObject.printAllBooksByDepartment(department); System.out.println("DONE"); break; }*/ case 11:{ System.out.println("Enter ID and ISBN:"); String ID = sc.nextLine(); ID = sc.nextLine(); String ISBN = sc.nextLine(); parentObject.borrowBookToStudent(ID, ISBN); System.out.println("DONE"); break; } case 12:{ System.out.println("Enter ID and ISBN:"); String ID = sc.nextLine(); ID = sc.nextLine(); String ISBN = sc.nextLine(); parentObject.returnBookFromStudent(ID, ISBN); System.out.println("DONE"); break; } case 13:{ parentObject.printBorrowedBookRegistry(); System.out.println("DONE"); break; } case 14:{ System.out.println("EXITING"); System.exit(1); break; } default: System.out.println("Wrong Choice"); } }

}

}

In this project, you will design and implement a library management system. The library management system will be for an engineering school that has the following departments Computer Engineering (CPEN), Electrical Engineering (ELEN). Industrial Engineering (IMEN) Mechanical Engineering (MEEN) and Civil Engineering (CIEN). The system will have the following requirements Each book has a title, author, ISBN number, number of pages, edition, publisher and engineering type (CPEN, ELEN, IMEN, MEEN or CIEN) There are faculty accounts that have first name, last name, ID, department, position (adjunct professor, assistant professor, professor) and amount of borrowed books There are student accounts that have first name, last name, ID, department, year and amount of borrowed books The library management system keeps track of books, and users by using files . * . . o One file handles book information o One file handles user information o One file registers a person and a borrowed book. * There is a Registry class that holds a borrower's ID and the ISBN number of the borrowed book. Students can only borrow up to 2 books at a time, Faculty can borrow up to 4 books When returning a book, you should input the amount of days the user held the book. The first 15 days are free, while extra days have a cost of S5 * . The program should have a menu that allows the following 1. Add a new book 2. Add a new user (ask if student or faculty) 3. Search for information about a specific book (use ISBN) 4. Delete a book (use ISBN) a. Check first if a user hasn't borrowed the book 5. Delete a user from the system a. Verify the user has returned all his books first 6. Show all books 7. Show all books borrowed by a specific user (use ID) 8. Show all books for a specific department 9. Borrow a book to a user 10. Return a book 11. Show every user and the books borrowed by useir In this project, you will design and implement a library management system. The library management system will be for an engineering school that has the following departments Computer Engineering (CPEN), Electrical Engineering (ELEN). Industrial Engineering (IMEN) Mechanical Engineering (MEEN) and Civil Engineering (CIEN). The system will have the following requirements Each book has a title, author, ISBN number, number of pages, edition, publisher and engineering type (CPEN, ELEN, IMEN, MEEN or CIEN) There are faculty accounts that have first name, last name, ID, department, position (adjunct professor, assistant professor, professor) and amount of borrowed books There are student accounts that have first name, last name, ID, department, year and amount of borrowed books The library management system keeps track of books, and users by using files . * . . o One file handles book information o One file handles user information o One file registers a person and a borrowed book. * There is a Registry class that holds a borrower's ID and the ISBN number of the borrowed book. Students can only borrow up to 2 books at a time, Faculty can borrow up to 4 books When returning a book, you should input the amount of days the user held the book. The first 15 days are free, while extra days have a cost of S5 * . The program should have a menu that allows the following 1. Add a new book 2. Add a new user (ask if student or faculty) 3. Search for information about a specific book (use ISBN) 4. Delete a book (use ISBN) a. Check first if a user hasn't borrowed the book 5. Delete a user from the system a. Verify the user has returned all his books first 6. Show all books 7. Show all books borrowed by a specific user (use ID) 8. Show all books for a specific department 9. Borrow a book to a user 10. Return a book 11. Show every user and the books borrowed by useir

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions