Design A Library Management System
Design A Library Management System
System Requirements
10. Each book and member card will have a unique barcode. The
system will be able to read barcodes from books and members’
library cards.
Use case diagram
(/learn)
Here are the top use cases of the Library Management System:
Class diagram
BookItem: Any book can have multiple copies, each copy will be
considered a book item in our system. Each book item will have
a unique barcode.
ClassName
property_name: type Class: Every class can have properties and methods.
Abstract classes are identified by their Italic names.
method(): type
A B Generalization: A implements B.
Activity diagrams
[no]
[yes]
(/learn)
System checks the number of books issued to the member
[else]
[yes]
[no]
System updates the status of the book to 'Loaned' Show error message
[no]
Calculate fine
[yes]
[no]
[no]
Calculate fine
[yes]
[no]
Here is the code for the use cases mentioned above: 1) Check-out a
book, 2) Return a book, and 3) Renew a book.
Note: This code only focuses on the design part of the use cases. Since
you are not required to write a fully executable code in an interview,
you can assume parts of the code to interact with the database,
payment system, etc.
Enums and Constants: Here are the required enums, data types, and
constants:
Java Python
public enum BookFormat {
HARDCOVER, (/learn)
PAPERBACK,
AUDIO_BOOK,
EBOOK,
NEWSPAPER,
MAGAZINE,
JOURNAL
}
if (!bookItem.checkout(this.getId())) {
return false;
}
this.incrementTotalBooksCheckedout();
return true;
}
Java Python
public class BookReservation {
(/learn)
private Date creationDate;
private ReservationStatus status;
private String bookItemBarcode;
private String memberId;
Java Python
public abstract class Book {
(/learn)
private String ISBN;
private String title;
private String subject;
private String publisher;
private String language;
private int numberOfPages;
private List<Author> authors;
}
Search interface and Catalog: The Catalog class will implement the
Search interface to facilitate searching of books.
Java Python
public interface Search {
public List<Book> (/learn)
searchByTitle(String title);
public List<Book> searchByAuthor(String author);
public List<Book> searchBySubject(String subject);
public List<Book> searchByPubDate(Date publishDate);
}
← Back Next →
(/courses/grokking- Mark(/courses/grokking-
as Completed
the- the-
object- object-
oriented- oriented-
Activity Diagrams
design- Design design-
a Parking Lot
interview/B8RPL3VEl8N) interview/gxM3gRxmr8Z)
Stuck? DISCUSS
Get (https://discuss.educative.io/c/grokking-the-object-oriented- 25
Send
help design-interview-design-gurus/object-oriented-design- Recommendations
feedback
on case-studies-design-a-library-management-system)