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 TypeAFactory class shown in the following code extends the MotorHomeAbstractFactory class:
public class TypeAFactory extends MotorHomeAbstractFactory { public Frame createFrame() { return new TypeAFrame(); } public Style createStyle() { return new TypeAStyle(); } public Engine createEngine() { return new TypeAEngine(); } public Kitchen createKitchen() { return new TypeAKitchen(); }}
In addition to a Factory class, we need a class to implement the class hierarchy. Here, you see can each of the interfaces that were implemented:
public class TypeAStyle implements Style { public String getStyle() { return "[Type A] ...
Read now
Unlock full access