Hey everyone and thanks for taking the time to read my 1st post. Quite new to java and would appreciate if anyone could help me out with the following problems in my program. I am designing a program for a small classroom library. The code is below. The main application menu class, a loanBook class and a pupil helper class. Whats confusing me is trying to create and link up the the menu options of display available books, borrow book, and loan book. I have included the code and hope that some of you can give me any advice to help me. Thanks in advance.
public class bookArray { static Scanner keyboard = new Scanner(System.in); loanBook [] bookArray = new loanBook[5]; static String title, author, status; public void addBook () { for (int count=0; count<bookArray.length; count++) { System.out.println("Please enter the book title :\t"); title = keyboard.nextLine(); System.out.println("Please enter the book author :\t"); author = keyboard.nextLine(); status = "Available"; bookArray[count] = new loanBook(title, author); } } public void displayAvailableBooks () { } public void displayBooksOnLoan () { } public void borrowBook () { } public void returnBook () { } static void displayMenu () { int menuChoice; System.out.println("Welcome to the Class Library System\n"); System.out.println("1.\tAdd Book\n"); System.out.println("2.\tDisplay available books\n"); System.out.println("3.\tDisplay books currently on loan\n"); System.out.println("4.\tBorrow Book\n"); System.out.println("5.\tReturn Book\n"); System.out.println("6.\tWrite book details to file\n"); System.out.println("7.\tExit\n"); // Prompt user to choose an option System.out.println("Please choose one of the above options: "); // Store users' choice as a variable menuChoice = keyboard.nextInt(); switch (menuChoice)..............
loanBook class
public class loanBook { String title, author, status; private int bookId; static int count=1; private pupil pupil; public loanBook (String title, String author) { this.title = title; this.author = author; this.status = "Available"; this.bookId = count; count ++; } }
pupil class
public class pupil { private String firstname, surname; private Scanner keyboard = new Scanner(System.in); public pupil (String firstname, String surname) { this.firstname = firstname; this.surname = surname; } public String toString() { return (firstname + surname); } public void getPupil() { System.out.println("Please enter pupils first name : "); firstname = keyboard.nextLine(); System.out.println("Please enter pupils surname : "); surname = keyboard.nextLine(); } }