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 TypeBFactory class shown here extends the MotorHomeAbstractFactory class:
public class TypeBFactory extends MotorHomeAbstractFactory { public Frame createFrame() { return new TypeBFrame(); } public Style createStyle() { return new TypeBStyle(); } public Engine createEngine() { return new TypeBEngine(); } public Kitchen createKitchen() { return new TypeBKitchen(); }}
In addition to a Factory class, we need a class to implement the class hierarchy. Here, you can see each of the interfaces implemented:
public class TypeBStyle implements Style { public String getStyle() { return "[Type B] Style:\t\tWeekender"; }}public ...
Read now
Unlock full access