Run the program and check the errors 1 package methods.lab12; 2 3 import java.io.*; 4 import java.util.*;
Fantastic news! We've Found the answer you've been seeking!
Question:
Run the program and check the errors
1 package methods.lab12;2
3 import java.io.*;
4 import java.util.*;
5 import classes.lab12.Book;
6
7 /**
8 * The class contains a set of methods required for the lab to work properly
9 *
10 * @NOTE. All parameters passed to method must be passed as final. You don't need to write a default value constructor
11 * since we don't have any class level variable.
12 */
13 public class Lab12Methods
14 {
15 /**
16 * Don't write this constructor it is provided by Java
17 */
18 public Lab12Methods(){}
19
20 /**
21 * The fillArray method first creates an array of books, and then fills each index of the book array with
22 * a new Book object.
23 * @NOTE. The rule for first and last name applys from the last lab
24 *
Y. Daniel Liang -> first is Y. Daniel and last is Liang
25 *
26 * @param fin Representing the Scanner object to the file
27 * @param total Representing the total number of elements to be contained in the array
28 * @return Book [] Representing array filled with Book objects
29 *
30 * @throws IllegalArgumentException if fin is null
31 * @throws IllegalArgumentException if total is less than 1
32 *
33 * @NOTE. The file contents are comma separated values in the order title, isbn, pages, authors
34 */
35 public static Book [] fillArray(final Scanner fin, final int total)
36 {
37 return null;
38
39 }// end fillArray
40
41 /**
42 * The printBooks calls the toString method of book and prints each book out followed by a CR
43 *
44 * @param array Representing the array of books
45 * @param output Representing the PrintStream object to the screen or the file
46 *
47 * @throws IllegalArgumentException if array is null or the length is < 1
48 * @throws IllegalArgumentException if output stream is null
49 */
50 public static void printBooks(final Book [] array, final PrintStream output)
51 {
52
53 }// end printBooks
54
55
56 /**
57 * The menu method offers the user a choice from:
58 * 1) Print the books to the screen
59 * 2) Print the books to a file
60 * 3) Sort the books based on natural order
61 * 4) Sort the books based on total order of Book ISBN
62 * 5) Add a new book to the bookshelf
63 * 6) Search the bookshelf for a book
64 * 7) Sort the books based on total order of author last name and first name
65 * 8) Quit
66 *
67 * @param kb Representing the Scanner object to the keyboard
68 * @return int Representing the menu choice which is ensured by you
69 * to be between 1 and 8 inclusive
70 *
71 * @throws IllegalArgumentException if kb is null
72 *
73 * @NOTE. You must ensure the input buffer is empty at the end of the method
74 */
75 public static int menu(final Scanner kb)
76 {
77 if(kb == null)
78 throw new IllegalArgumentException("bad scanner menu");
79
80 int choice;
81 do
82 {
83 System.out.println("Please choose from the following");
84 System.out.println("1) Print the books to the screen");
85 System.out.println("2) Print the books to a file");
86 System.out.println("3) Sort the books based on natural order");
87 System.out.println("4) Sort the books based on total order of Book ISBN");
88 System.out.println("5) Add a new book to the bookshelf");
89 System.out.println("6) Search the bookshelf for a book");
90 System.out.println("7) Sort the books based on the total order of the Author Last Name and First Name");
91 System.out.println("8) Quit");
92 System.out.print("Choice --> ");
93 choice = Integer.parseInt(kb.nextLine());
94 System.out.println();
95 }while(choice < 1 || choice > 8);
96
97 return choice;
98 }// end menu
99
100
101 /**
102 * The addBook method makes a new array of the old size plus one
103 * Next it copies the books from the old array to the new array
104 * Next it adds the new book in last index of the new array
105 *
106 * @param array Representing the old array to be copied
107 * @param aBook Representing the book to add to the array
108 * @return Book [] Representing the new array with the old books copied over
109 * and the new book in the last index of the new array.
110 *
111 * @throws IllegalArgumentException if array is null or length < 1
112 * @throws IllegalArgumentException if aBook is null
113 *
114 * @NOTE. You must ensure the input buffer is empty at the end of the method
115 */
116 public static Book[] addBook(final Book [] array, final Book aBook)
117 {
118 return null;
119 }// end addBook
120
121 /**
122 * The createBook method prompts the user to enter title, isbn, pages, and author.
123 * Author is prompted for first, last and publisher
124 * @NOTE. The rule for first and last name applys from the last lab
125 *
Y. Daniel Liang -> first is Y. Daniel and last is Liang
126 * Entering the information is done by the private method readString.
127 * The method must ensure that the pages is > 0
128 *
129 * @param kb Representing the Scanner object to the keyboard
130 * @return Book Representing a new Book object
131 *
132 * @throws IllegalArgumentException if kb is null
133 *
134 * @NOTE. You must ensure the input buffer is empty at the end of the method
135 */
136 public static Book createBook(final Scanner kb)
137 {
138 return null;
139 }// end createBook
140
141 /**
142 * The readOutputFilename calls the readString to read a output filename
143 *
144 * @param kb Representing the Scanner object to the keyboard
145 * @return String Representing the output filename
146 *
147 * @throws IllegalArgumentException if kb is null
148 *
149 * @NOTE. You must ensure the input buffer is empty at the end of the method
150 */
151 public static String readOutputFilename(final Scanner kb)
152 {
153 return null;
154 }
155
156 /**
157 * The readString reads a string from the keyboard and ensures the string is not null or empty
158 *
159 * @param type Representing a String for the prompt on what to enter
160 * @param kb Representing the Scanner object to the keyboard
161 * @return String Representing the appropriate String
162 *
163 * @throws IllegalArgumentException if kb is null
164 *
165 * @NOTE. You must ensure the input buffer is empty at the end of the method
166 */
167 private static String readString(final String type, final Scanner kb)
168 {
169 String str="";
170 return str;
171 }// end readString
172
173 }// end class
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date: