Class Card
Class Diagram
Menu
Remove Method
if(textbook.get(index).getBookName().contains(booktoremove))
We loop the whole textbook arraylist to find the book that contains some particular characters inside the bookname. We store those characters inside a string called booktoremove. We use getBookName() to get the name of each textbook object from the textbook arraylist . After discovering the textbook, we use remove() which is a method from Arraylist Class to remove the textbook object that we found.
For Loop Method
for(BookSL Book : textbook)
We loop all book object from the arraylist called textbook. Each object in the textbook array list is declared as Book(the 2nd one). Both Book(the 2nd one) and textbook is from BookSL Class.
Add Method
We add a new student object in the Arraylist called studentList. We create a new student object from the StudentSL class with a studentName.
Search Method
We input a studentID and expect an output of the index of that student object in studentlist Arraylist. If we cannot find the student, we output -1. We loop all student object inside studentlist arraylist. If the studentID of a student equals to the studentID that we input, we will return the index of that student object.
Borrow Method
Only when there is a student object with studentID that we input and a book object with bookID that we input (not null), the student are able to borrow the book. Then we access to the borrowBook() inside student class to borrow the book.
Get Method
We input bookID and expect the system to return a book object. We use internal method call to call searchTextbookByID() which output the index of a book object. We use the get() method from the ArrayList Class to get the book object from the textbook arraylist.
Personal Reflection
By writing this project by myself, I am more familiar with those methods and syntax. I learned a very important approach as well. When I am trying to write a method, I have to consider what is the input, what is the ouput, and how to implement other methods to convert the input to the output that I want to get. Ver excited! I should practice more!