SmartLibrary

Class Card

6632559802978087651.png

Class Diagram

Screen Shot 2017-04-21 at 3.12.46 PM.png

Menu

Screen Shot 2017-04-21 at 2.12.28 PM.pngScreen Shot 2017-04-21 at 2.13.16 PM

Remove Method

Screen Shot 2017-04-21 at 3.12.01 PM.png

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

Screen Shot 2017-04-21 at 3.21.55 PM.png

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

Screen Shot 2017-04-21 at 3.39.56 PM.png

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

Screen Shot 2017-04-21 at 4.02.20 PM.png

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

Screen Shot 2017-04-21 at 4.05.34 PM.png

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.

Screen Shot 2017-04-21 at 4.11.11 PM.png

Get Method

Screen Shot 2017-04-21 at 4.11.50 PM.png

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!

 

留下评论