import javax.swing.*; class LibraryMain { // Creates a staff of employees public static void main(String[] args) { // Sets up the list of books. Books[] BookList; BookList = new Books[5]; BookList[0] = new Books("Title1", "Author1", "Book1"); BookList[1] = new Books("Title2", "Author2", "Book2"); BookList[2] = new Books("Title3", "Author3", "Book3"); BookList[3] = new Books("Title4", "Author4", "Book4"); BookList[4] = new Books("Title5", "Author5", "Book5"); // creates object to print out details Borrowers personnel = new Borrowers(); personnel.records(); System.exit(0); // exits } } class Borrowers { public Students[] BorrowersList; public Borrowers() { // Sets up the list of borrowers. BorrowersList = new Students[4]; BorrowersList[0] = new Students("Student1", "S1", "", ""); BorrowersList[1] = new Students("Student2", "S2", "Book1", ""); BorrowersList[2] = new Students("Student3", "L3", "Book5", ""); BorrowersList[3] = new Students("Student4", "L4", "Book3", "Book5"); for (int count = 0; count < 1; count++) { // loop to continue to enter books // gets student ID String num = JOptionPane.showInputDialog(null, "Enter the Student ID", "Library System", JOptionPane.QUESTION_MESSAGE); // gets bookid String num2 = JOptionPane.showInputDialog(null, "Enter the Book ID", "Library System", JOptionPane.QUESTION_MESSAGE); System.out.println("\n"); // finds if any one has that book boolean is_available = true; for (int count2 = 0; count2 < 4; count2++) { if (BorrowersList[count2].bookid1.equals(num2)) { System.out.println("Sorry, the book is not available..."); is_available = false; break; } } for (int count3 = 0; count3 < 4; count3++) { if ((is_available == true) && (BorrowersList[count3].ID.equals(num))) { BorrowersList[count3].bookid1 = num2; break; } } } } public void records() { // prints out borrowers details for (int count = 0; count < BorrowersList.length; count++) { System.out.println(BorrowersList[count]); System.out.println("-----------------------------------"); } } } class Students { protected String name; protected String ID; protected String bookid1; protected String bookid2; // Sets up students with the information. public Students(String sName, String sID, String sBookid1, String sBookid2) { name = sName; ID = sID; bookid1 = sBookid1; bookid2 = sBookid2; } // Returns information about the students as a string. public String toString() { String result = "Name : " + name + "\n"; result += "ID : " + ID + "\n"; result += "Books borrowed : " + bookid1 + " " + bookid2; return result; } } class Books { protected String title; protected String author; protected String ISBN; // Sets up books with the information. public Books(String sName, String sID, String sBookid) { title = sName; author = sID; ISBN = sBookid; } }