April 2019
Intermediate to advanced
360 pages
9h 17m
English
Our solution includes a Factory class for each of the three types of motor homes (type A, type B, and type C). The TypeCFactory class shown in the following code extends the MotorHomeAbstractFactory class:
public class TypeCFactory extends MotorHomeAbstractFactory { public Frame createFrame() { return new TypeCFrame(); } public Style createStyle() { return new TypeCStyle(); } public Engine createEngine() { return new TypeCEngine(); } public Kitchen createKitchen() { return new TypeCKitchen(); }}
In addition to a Factory class, we need a class to implement the class hierarchy. Here, you can see each of the interfaces that were implemented:
public class TypeCStyle implements Style { public String getStyle() { return "[Type C] ...
Read now
Unlock full access