This project demonstrates three design patterns implemented in Java: Observer Pattern, Factory Method Pattern, and Adapter Pattern. Each pattern is implemented in separate classes with a Main file to demonstrate the functionality.
- Java 17 or later: Ensure you have Java Development Kit (JDK) version 17 or above installed.
- Maven 3.x or later: The project uses Maven for dependency management and build automation.
- CarFactory: Factory class for creating different types of cars
- LegacyReservation: Legacy reservation system class
- LuxuryCar: Implementation of luxury car type
- Main: Main class to demonstrate pattern usage
- Mediator: Interface for mediator pattern
- MessageMediator: Implementation of message mediator
- NormalCar: Implementation of standard car type
- Observer: Interface for observer pattern
- ReservationAdapter: Adapter for reservation system
- ReservationSystem: Interface for reservation system
- Rider: Class representing a rider
- RiderObserver: Implementation of rider observer
- ShareableCar: Interface for shareable cars
- SUVCar: Implementation of SUV car type
- WheelchairAccessibleCar: Implementation of wheelchair accessible car type
Includes the following test classes:
- RiderMediatorTest.java: Tests the Observer Pattern implementation
- CarFactoryTest.java: Tests the Factory Method Pattern implementation
- ReservationAdapterTest.java: Tests the Adapter Pattern implementation
git clone https://github.com/naim1115/SoftwareEngineeringHW4.git
cd SoftwareEngineeringHW4
Use Maven to compile the project:
mvn clean install
Execute the Main class to see the demonstration of all three patterns:
mvn exec:java -Dexec.mainClass="Main"
The test folder contains individual test cases for each pattern. Run the tests using Maven:
mvn test
The project uses the following dependency:
- JUnit 5: Version 5.11.3 for testing. Specified in the pom.xml file:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.11.3</version>
</dependency>
- Pattern Implementation: Each design pattern is implemented in its respective classes with clear separation of concerns.
- Test Structure: Each pattern has a dedicated test class for clarity.