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 checkin(String holder)
Given the following codes:
import java.io.File;
import java.io.FileNotFoundException;
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 add(long isbn, String author, String title){
library.add(new LibraryBook(isbn, author, title));
}
/* Add the list of library books to the library, assume no duplicates.*/
public void addAll(ArrayList list){
library.addAll(list);
}
/* 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 addAll(String filename){
ArrayList toBeAdded = new ArrayList();
try {
Scanner fileIn = new Scanner(new File(filename));
int lineNum =1;
while (fileIn.hasNextLine()){
String line = fileIn.nextLine();
Scanner lineIn = new Scanner(line);
lineIn.useDelimiter("\\t");
if (!lineIn.hasNextLong())
throw new ParseException("ISBN", lineNum);
long isbn = lineIn.nextLong();
if (!lineIn.hasNext())
throw new ParseException("Author", lineNum);
String author = lineIn.next();
if (!lineIn.hasNext())
throw new ParseException("Title", lineNum);
String title = lineIn.next();
toBeAdded.add(new LibraryBook(isbn, author, title));
lineNum++;
}
} catch (FileNotFoundException e){
System.err.println(e.getMessage()+" Nothing added to the library.");
return;
} catch (ParseException e){
System.err.println(e.getLocalizedMessage()
+" formatted incorrectly at line "+ e.getErrorOffset()
+". Nothing added to the library.");
return;
}
library.addAll(toBeAdded);
}
/* 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 lookup(long isbn){
int index =0;
boolean find_Holdder_flag = false;
return null; //place holder
}
public boolean checkout(long isbn, String holder, int month, int day, int year){
boolean checkout_flag = false;
return checkout_flag;
}
/*** 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 lookup(String holder){
return null; //placeholder
}
/* IISBN of the library book to be checked in */
public boolean checkin(long isbn){
int index =0;
if (library.size()>0){
for (index =0; index < library.size(); index++){
if (library.get(index).getIsbn()== isbn)
{
return true;
}
}// end of for loop
}
return false; // placeholder
}
/* holder of the library books to be checked in*/
public boolean checkin(String holder){
int index =0;
if (library.size()>0){
for (index =0; index < library.size(); index++){
if (library.get(index).getHolder()== 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!