Question: Im not quite under standing the following Code, I have the enum file and understand that part, but I am struggling with taking in the

Im not quite under standing the following Code, I have the enum file and understand that part, but I am struggling with taking in the object, then searching the arrayList for that object, and then how would I add the new object to the array. Im not quite under standing the following Code, I have the enum

addBook(Book book)

If the Reader already has a copy of book addBook returns a Code.BOOK_ALREADY_CHECKED_OUT_ERROR;

Otherwise add the book to the List of books in the reader object and return a Code.SUCCESS;

import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.sql.SQLOutput; import java.time.LocalDate; import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.Scanner; import java.util.ArrayList;

import static java.util.Arrays.*;

public class Reader{ private int cardNumber; private String name; private String phone; private List books;

int CARD_NUMBER_=0; int NAME_=1; int PHONE_=2; int BOOK_COUNT_=3; int BOOK_START_=4;

public Reader(int cardNumber, String name, String phone) { this.cardNumber = cardNumber; this.name = name; this.phone = phone; }

public int getCardNumber() { return cardNumber; } public void setCardNumber(int cardNumber) { this.cardNumber = cardNumber; }

public String getName() { return name; } public void setName(String name) { this.name = name; }

public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; }

public List getBooks() { return books; }

public void setBooks(List books) { this.books = books;

}

Code addBook(Book book){ boolean CheckforBook = false;

Book addingBook = new Book(" ", " ", " ", " ", 0, LocalDate.now() ); System.out.println("Which Would you like to add? ");

return Code.SUCCESS; }

Code removeBook(Book Book){

return Code.SUCCESS; }

Code hasBook(Book Book){

return Code.SUCCESS; }

@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Reader)) return false; if (!super.equals(o)) return false; Reader reader = (Reader) o; return getCardNumber() == reader.getCardNumber() && getName().equals(reader.getName()) && getPhone().equals(reader.getPhone()) && getBooks().equals(reader.getBooks()); }

@Override public int hashCode() { return Objects.hash(super.hashCode(), getCardNumber(), getName(), getPhone(), getBooks()); }

@Override public String toString() { return " " + name +"(#" + cardNumber + ") has checked out: " + books; }

public static void main(String[] args){

Reader reader = new Reader(0, " ", " ");

Scanner scan = new Scanner((System.in)); System.out.println("What is the file path?"); // take in csv file String CSVpath = scan.nextLine(); String line=" "; try{ BufferedReader readCSV = new BufferedReader(new FileReader(CSVpath)); while((line = readCSV.readLine()) != null) { String[] CSV_values = line.split(","); //splits array by commas

}

} catch (FileNotFoundException fileNotFoundException) { fileNotFoundException.printStackTrace(); } catch (IOException ioException) { ioException.printStackTrace(); }

}

}

Code addBook (Book book){ boolean CheckforBook = false; author" subject pagecount: 0, LocalDate.now(); Book addingBook = new Book( isbn:"", title: System.out.println("Which Would you like to add ? "); return Code. SUCCESS; } Code removeBook (Book Book){ return Code .SUCCESS; } Code hasBook (Book Book) { return Code. SUCCESS; }

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 Databases Questions!