Cab Booking Application using Design Patterns
This is a simple Cab Booking application implemented in Java. The application uses various design patterns such as Singleton, Abstract Factory, Strategy, and Proxy to manage different aspects of the booking process.
The Cab Booking Application is designed to provide users with a convenient way to book different types of cabs, including Prime Sedan, Mini, and Auto. The application incorporates design patterns to enhance modularity, extensibility, and maintainability.
- User authentication with regular and subscription pricing strategies.
- Booking of Prime Sedan, Mini, and Auto vehicles.
- Different features available for each vehicle type.
The application leverages the following design patterns:
-
Singleton Pattern: Ensures that there is only one instance of the
BookingManager
class to manage cab bookings. -
Abstract Factory Pattern: Provides an interface for creating families of related or dependent objects. Factories include
PrimeSedanFactory
,MiniFactory
, andAutoFactory
. -
Strategy Pattern: Defines a family of algorithms, encapsulates each algorithm, and makes them interchangeable. Strategies include pricing strategies (
RegularPricing
andSubscriptionPricingStratergy
) and features strategies (ACStratergy
,noFeaturesStratergy
,wifiandACStratergy
). -
Proxy Pattern: Acts as a surrogate or placeholder for another object to control access to it. The
ProxySubscriber
class is used to authenticate and apply pricing strategies based on the user's subscription status.
-
Clone the repository:
git clone https://github.com/your-username/cab-booking-app.git
-
Compile and run the application:
cd cab-booking-app javac cabBook.java java cabBook
-
Follow the on-screen prompts to authenticate, choose a vehicle type, and book a cab.
- Java SDK (version X.X.X)
- Scanner class (standard Java library)
-Image below shows that the user is a subscriber and has discount applied on cab rides