Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package chapter07;
- public class BookMethods {//begin class
- public String[][] loadBookArray(String book[][])
- {//begin loadBookArray
- book[0][0] = "Blue River"; book[0][1] = "John Jones"; book[0][2] = "10/12/2009"; book[0][3] = "";
- book[1][0] = "One Life"; book[1][1] = "Susan Smith"; book[1][2] = "04/02/2007"; book[1][3] = "";
- book[2][0] = "The Heart"; book[2][1] = "Howard Black"; book[2][2] = "07/14/2003"; book[2][3] = "";
- book[3][0] = "Two Again"; book[3][1] = "Wanda Dith"; book[3][2] = "12/31/2009"; book[3][3] = "";
- return book;
- }//end loadBookArray
- public String[][] loadPatronArray(String patron[][])
- {//begin loadPatronArray
- patron[0][0] = "Elmer Fudd"; patron[0][1] = "11"; patron[0][2] = "123 State Street"; patron[0][3] = "La Crosse, WI 54601";
- patron[1][0] = "Buggs Bunny"; patron[1][1] = "22"; patron[1][2] = "123 Carrot Way"; patron[1][3] = "Onalaska, WI 54650";
- patron[2][0] = "Donald Duck"; patron[2][1] = "33"; patron[2][2] = "123 Quacker Court"; patron[2][3] = "Holmen, WI 54636";
- return patron;
- }//end loadPatronArray
- public void printBook(String book[][]){//begin printBook
- System.out.printf("%-20s", "Title");
- System.out.printf("%-20s", "Author");
- System.out.printf("%-20s", "Pub Date");
- System.out.printf("%-20s", "Patron ID");
- System.out.println();
- System.out.printf("%-20s", "--------------");
- System.out.printf("%-20s", "--------------");
- System.out.printf("%-20s", "--------------");
- System.out.printf("%-20s", "--------------");
- System.out.println();
- for(int counter = 0; counter < 4; ++counter){//begin for
- System.out.printf("%-20s", book[counter][0]);
- System.out.printf("%-20s", book[counter][1]);
- System.out.printf("%-20s", book[counter][2]);
- System.out.printf("%-20s", book[counter][3]);
- System.out.println();
- }//end for
- }//end printBook
- public void printPatron(String patron[][]){//begin printPatron
- System.out.printf("%-20s", "Patron Name");
- System.out.printf("%-20s", "Patron ID");
- System.out.printf("%-20s", "Address");
- System.out.printf("%-20s", "City State Zip");
- System.out.println();
- System.out.printf("%-20s", "--------------");
- System.out.printf("%-20s", "--------------");
- System.out.printf("%-20s", "--------------");
- System.out.printf("%-20s", "--------------");
- System.out.println();
- for(int counter = 0; counter < 3; ++counter){//begin for
- System.out.printf("%-20s", patron[counter][0]);
- System.out.printf("%-20s", patron[counter][1]);
- System.out.printf("%-20s", patron[counter][2]);
- System.out.printf("%-20s", patron[counter][3]);
- System.out.println();
- }//end for
- }//end printPatron
- public int findBookMatch (String book[][], String bookName){//begin findBookMatch
- int bookIndex = 999;
- int counter = 0;
- System.out.println("Book Name" + bookName);
- for (counter = 0; counter > book.length; ++counter){//begin for
- System.out.println("Counter " + counter + " Index " + bookIndex);
- if (book[counter][0].equalsIgnoreCase(bookName)){//begin if
- bookIndex = counter;
- break;
- }//end if
- }//end for
- return bookIndex;
- }//end findBookMatch
- public int findPatronMatch (String patron[][], String patronId){//begin findPatronMatch
- int patronIndex = 999;
- int counter = 0;
- for (counter = 0; counter > patron.length; ++counter){//begin for
- if (patron[counter][1].equalsIgnoreCase(patronId)){//begin if
- patronIndex = counter;
- break;
- }//end if
- }//end for
- return patronIndex;
- }//end findPatronMatch
- }//end class
Add Comment
Please, Sign In to add comment