COMP 303 Lecture Notes - Lecture 14: Null Pointer, Multiple Inheritance
Document Summary
14 template method pattern & protected interfaces: textbook chapter 6. 4 and 6. 5. Problem: i have steps to payment, and i want to do these steps in speci c ways. Solution: use the template method pattern to force the steps in a speci c order. Non-abstract method call the abstract methods to force a sequence of steps abstract methods. Subclasses add code to abstract methods to implement real actions abstract class paymentobject { bool makepayment(double amount) { Ans = pay(ptr, amount); return ans; abstract void paymentinfo(); abstract void connect(info info); abstract void pay(account ptr, double amount); // implement body of of abstract methods in child class creditcardpayment extends paymentobject { void paymentinfo() { } void connect(info info) { } void pay(account ptr, double amount) { } Note: deal with a set of subclass methods whose implementations are almost identical. Clericalsta member x = new clericalsta member( ); abstract class clericalsta member { }