class Book { private String name; private String author; private int ISBN; private int quantity; // Constructor // Getters/Setters } class Library { private Book[] books = new Book[50]; // limit to 50...

I need help doing this assignment


class Book { private String name; private String author; private int ISBN; private int quantity; // Constructor // Getters/Setters } class Library { private Book[] books = new Book[50]; // limit to 50 books private Student[] students = new Student[30]; // limit to 30 students public void addBook(String name, String author, int ISBN, int initialQuantity) { // add a new Book object to the books array (use next available slot in the array) // next available slot: is an index that is not null } public void updateBookQuantity(int ISBN, int input) { // find the book in the books array using the ISBN number // update the quantity based on input } public Book searchBookByISBN(int ISBN) { // search for the book in the books array using the ISBN // if found return the Book object, return null otherwise } public void printAllBooks() { // using the books array, if element is not null, print name, author, ISBN, initialQuantity } public void registerStudent(String name) { // add a new Student object to the students array (for this assignment, do not use "default constructor", use next available slot) } public void printRegisteredStudents() { // using the students array, if element is not null, print name, id and checkedOutBooks } public boolean isStudentRegistered(int studentId) { // return true if studentId exists in the students array, false otherwise } public int numOfBooksCheckedOutByStudent(int studentId) { // if you find the student using studentId return checkedOutBooks for this student, 0 otherwise } public void checkOutBook(int studentId, int ISBN) { // check some basic information before we checkout a book // if the student is not registered, immediately return and print an error on the screen // if the student is registered and has 3 checked out books, immediately return and print an error on the screen // if the ISBN does not exist in the books array, immediately return and print an error on the screen // if the ISBN exists, but all the books have been checked out (quantity == 0), immediately return and print an error on the screen // all tests pass, we are ready to checkout the book for this student // update checkedOutBooks field for this student by incrementing it by 1 // updateBookQuantity(ISBN, -1); } public void checkInBook(int studentId, int ISBN) { // check some basic information before we check-in a book // if the student is not registered, immediately return and print an error on the screen // if the student is registered and has 0 checked out books, immediately return and print an error on the screen // if the ISBN does not exist in the books array, immediately return and print an error on the screen // all tests pass, we are ready to check-in the book for this student // update checkedOutBooks field for this student by decrementing it by 1 // updateBookQuantity(ISBN, 1); } } class Student { // Use the Student class from lecture which has name and random id // add following field: private int checkedOutBooks; // number of books currently checked out by this student, max is 3! // Constructor // Getters/Setters }
Apr 02, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here