Bridge Design Pattern - Exp4
Bridge Design Pattern - Exp4
The bridge design pattern is a type of structural design pattern which is used to
split a large class into two separate inheritance hierarchies (a collection of 'is-
a' relationships); one for the implementations and one for the abstractions.
These hierarchies are then connected to each other via object composition,
forming a bridge-like structure. This pattern is also known as the Handle-Body
Design Pattern.
UML Diagram:
Source Code:
this.workShop1 = workShop1;
this.workShop2 = workShop2;
super(workShop1, workShop2);
@Override
System.out.print("Car ");
workShop1.work();
workShop2.work();
}
}
super(workShop1, workShop2);
@Override
System.out.print("Bike ");
workShop1.work();
workShop2.work();
interface Workshop
@Override
System.out.print("Produced");
}
}
@Override
System.out.print(" And");
System.out.println(" Assembled.");
class Main {
vehicle1.manufacture();
vehicle2.manufacture();