forked from PrajaktaSathe/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestFactoryPattern.java
More file actions
43 lines (37 loc) · 1.58 KB
/
TestFactoryPattern.java
File metadata and controls
43 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package factoryMethod;
public class TestFactoryPattern {
CarFactory carBuilder;
Car car;
public static void main(String[] args) {
TestFactoryPattern client = new TestFactoryPattern();
client.buildCarMethod();
}
public void buildCarMethod() {
System.out.println("Building Hatchback car...");
carBuilder = new HatchbackCarFactory();
car = carBuilder.buildCar("Polo", "Michelin", "VW");
System.out.println("Car is assembled!");
System.out.println("Specifications of car are: ");
System.out.println("Model: " + car.getModel());
System.out.println("Engine: " + car.getEngine());
System.out.println("Wheel: " + car.getWheel());
System.out.println();
System.out.println("Building Sedan car...");
carBuilder = new SedanCarFactory();
car = carBuilder.buildCar("Dzire", "MRF", "Suzuki");
System.out.println("Car is assembled!");
System.out.println("Specifications of car are: ");
System.out.println("Model: " + car.getModel());
System.out.println("Engine: " + car.getEngine());
System.out.println("Wheel: " + car.getWheel());
System.out.println();
System.out.println("Building SUV car...");
carBuilder = new SUVCarFactory();
car = carBuilder.buildCar("Innova", "Bridgestone", "Fiat");
System.out.println("Car is assembled!");
System.out.println("Specifications of car are: ");
System.out.println("Model: " + car.getModel());
System.out.println("Engine: " + car.getEngine());
System.out.println("Wheel: " + car.getWheel());
}
}