Question: Need to create public bollean checkin methods and test them. public boolean checkin ( long isbn ) public boolean checkin ( String holder ) Given
Need to create public bollean checkin methods and test them.
public boolean checkin long isbn
public boolean checkinString holder
Given the following codes:
import java.ioFile;
import java.ioFileNotFoundException;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.text.ParseException;
import java.util.Scanner;
Class representation of a library a collection of library books
public class Library
private ArrayList library;
private ArrayList libraryList;
public Library
library new ArrayList;
Add the specified book to the library, assume no duplicates.
public void addlong isbn, String author, String title
library.addnew LibraryBookisbn author, title;
Add the list of library books to the library, assume no duplicates.
public void addAllArrayList list
library.addAlllist;
Add books specified by the input file. One book per line with ISBN, author,
and title separated by tabs If file does not exist or format is violated, do nothing.
public void addAllString filename
ArrayList toBeAdded new ArrayList;
try
Scanner fileIn new Scannernew Filefilename;
int lineNum ;
while fileInhasNextLine
String line fileIn.nextLine;
Scanner lineIn new Scannerline;
lineIn.useDelimitert;
if lineIn.hasNextLong
throw new ParseExceptionISBN lineNum;
long isbn lineIn.nextLong;
if lineIn.hasNext
throw new ParseExceptionAuthor lineNum;
String author lineIn.next;
if lineIn.hasNext
throw new ParseExceptionTitle lineNum;
String title lineIn.next;
toBeAdded.addnew LibraryBookisbn author, title;
lineNum;
catch FileNotFoundException e
System.err.printlnegetMessage Nothing added to the library.";
return;
catch ParseException e
System.err.printlnegetLocalizedMessage
formatted incorrectly at line egetErrorOffset
Nothing added to the library.";
return;
library.addAlltoBeAdded;
Returns the holder of the library book with the specified ISBN.
If no book with the specified ISBN is in the library, returns null.
public String lookuplong isbn
int index ;
boolean findHoldderflag false;
return null; place holder
public boolean checkoutlong isbn, String holder, int month, int day, int year
boolean checkoutflag false;
return checkoutflag;
Returns the list of library books checked out to the specified holder.
If the specified holder has no books checked out, returns an empty list.
holder whose checked out books are returned
public ArrayList lookupString holder
return null; placeholder
IISBN of the library book to be checked in
public boolean checkinlong isbn
int index ;
if librarysize
for index ; index library.size; index
if librarygetindexgetIsbn isbn
return true;
end of for loop
return false; placeholder
holder of the library books to be checked in
public boolean checkinString holder
int index ;
if librarysize
for index ; index library.size; index
if librarygetindexgetHolder holder
return true;
end of for loop
return false; placeholder
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
