Question
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
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 } 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"); } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started