Abstract Factory Pattern

The Abstract Factory pattern uses a super-factory that creates concrete Factories. This is a creational pattern that provides one of the best ways to create an object.

An interface is responsible for creating a factory of related objects. Each generated factory can create objects using the Factory pattern.

Implementation

We will use the Vehicle interface and will add a color interface and concrete classes that implement these interfaces. We create the AbstractFactory and concrete classes that implement this interface. Then we will create a FactoryProducer.

Vehicle.java

Car.java

Motorcicle.java

Truck.java

Color.java

Red.java

Green.java

Blue.java

AbstractFactory.java

VehicleFactory.java

ColorFactory.java

FactoryProducer.java

Demo.java

 

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *