package edu.redwoods.template;
public abstract class HouseTemplate {
// Template method (i.e. the algorithm), **final** so subclasses can't override
public final void buildHouse(){
buildFoundation();
buildPillars();
buildWalls();
buildWindows();
System.out.println("House is built.");
}
// Default implementation (AKA **Hook** Methods!)
private void buildWindows() {
System.out.println("Building Glass Windows");
}
// Parts of the algorithm that vary, so methods are implemented by sub-classes
public abstract void buildWalls();
public abstract void buildPillars();
private void buildFoundation() {
System.out.println("Building foundation with cement,iron rods and sand");
}
}