Smart Library Project

As mentioned in the last blog post, I finished this little project! This blog post will explain the features as well as some of the core ideas in this program.

The Class Diagram

Picture1.png

Here is the class diagram of my Smart Library Project. This time I finished both the Student class and Book class, as well as the main menu created in the Library class.

To interact in with the users, I used a main method in Library Class. I will talk through the menus and functions in the rest of my blog.

Terminal Window

5

As we call the main method, this window appears, and the main menu shows up. I did not write this menu in the main method, in fact, my main menu is very short. I did this by creating the menus in the library class.

This slideshow requires JavaScript.

Here is the class card of the three classes. For some methods, I made them private, since they are only going to be called with the class. For example, private methods that return student object and book object are very useful. Since the parameter is ID, you can input an ID and then the methods will return the actual objects. Then, we can use dot notation to call the methods of the Student class and Book class.

6

Here is the student menu. In this menu, we can add student, remove student, search students, which are functions that I discussed in my previous blog post.

7

This is also discussed in my previous blog post. Actually, the student class resembles the Book class. The difference is that there is an ArrayList in the Student class, which contains the books that one student borrows.

8

This is the Borrow/Return Menu, which I added a last. This is more difficult than the previous menus since it include borrow and return methods.

11.png

This is the most difficult method in this program. It firstly asks for the student ID to find the student. Then it brings the student’s book collection back to the book system. Since each book has an Unique ID, as the book object is returned, its ID will not change. The key of successfully creating this return method is that I created a return method also in the student class.

12.png

This method is in Student class. The difficulty of returning book is to remove the book from student’s collection and add the book back to the book system. Here, I pass a argument, which is the ArrayList textbook (the book system), into this method. Therefore, I can simply remove the book by “collection.remove(i).” The same method is applied to adding the book back to the book collection of the library.

This is the words that show up as the program ends.

9

Thanks you for reading this post! If you want to play around with this program, you can contact me in the comments!

Leave a comment

Website Built with WordPress.com.

Up ↑