Skip to content

Solution to Assignment 4 of Software Systems and Design course

Notifications You must be signed in to change notification settings

wkwtfigo/Simplified-Book-Store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Simplified Book Store System

A simple console-based BookStore system implemented in Java, demonstrating several classic software design patterns including Singleton, Builder, Observer (Publisher-Subscriber), Strategy, and Facade. This application allows users to register, subscribe for notifications, read books, and (for premium users) listen to audiobooks.

Features

  • πŸ“• Add new books to the bookstore (with title, author, and price).

  • πŸ‘€ Register new users (standard or premium).

  • πŸ“¬ Subscribe/unsubscribe users for price update notifications.

  • πŸ’° Update book prices and automatically notify subscribers.

  • πŸ“– Allow users to read books.

  • 🎧 Allow premium users to listen to audiobooks.

Design Patterns Used

Pattern Purpose
Singleton Ensure a single instance of BookStore throughout the application.
Builder Simplify the creation of complex Book objects via a fluent interface.
Observer Allow users to subscribe and receive notifications when book prices change.
Strategy Define flexible behaviors for reading and listening to books for different user types.
Facade Provide a simple, unified interface for interacting with the bookstore system.

How to Run

  1. Clone the Repository

    git clone https://github.com/yourusername/Simplified-Book-Store.git
    cd Simplified-Book-Store
  2. Compile and Run

    javac Main.java
    java Main
  3. Available Console Commands

  • createBook <title> <author> <price>

  • createUser <user_type> <username> (user_type = standard or premium)

  • subscribe <username>

  • unsubscribe <username>

  • updatePrice <title> <new_price>

  • readBook <username> <title>

  • listenBook <username> <title>

  • end β€” to terminate the program

Example Session

createBook Dune Herbert 20
createUser premium Alice
createUser standard Bob
subscribe Alice
updatePrice Dune 25
readBook Alice Dune
listenBook Alice Dune
listenBook Bob Dune
end

Output:

Alice notified about price update for Dune to 25
Alice reading Dune by Herbert
Alice listening Dune by Herbert
No access

Project Structure

.
β”œβ”€β”€ Main.java          // Application entry point with command parser
β”œβ”€β”€ BookStore.java     // Singleton bookstore with Observer logic
β”œβ”€β”€ Facade.java        // Simplified interface for external interaction
β”œβ”€β”€ Book.java          // Book class with Builder pattern
β”œβ”€β”€ User.java          // User base class + StandardUser & PremiumUser
β”œβ”€β”€ ReadingBehavior.java, ListenBehavior.java
β”œβ”€β”€ CanRead.java, CanListen.java, CanNotListen.java // Strategy implementations
└── Observable.java    // Observer interface

About

Solution to Assignment 4 of Software Systems and Design course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages