Open main menu

CDOT Wiki β

Changes

Template Method

768 bytes removed, 16:12, 19 March 2007
Code Samples
== UML Diagram ==
== Pseudo Code Samples == Java:
<pre>
abstract class CheckBackground AbstractRenderer{ // Define the order in which the graphical routines should be executed public abstract void checkBankrender(); public abstract void checkCredit(); { public abstract void checkLoan(); // First draw the graphics public abstract void checkStock drawGraphics(); public abstract void checkIncome();   //work as template methodThen draw the GUI on top of the graphics public void check() { checkBank drawGUI(); checkCredit(); } checkLoan(); checkStock void drawGraphics(); checkIncome void drawGUI(); }
}
class LoanApp Renderer extends CheckBackground { private String name; public LoanApp(String name) { this.name = name; } AbstractRenderer public String getName() { return name; }  public void checkBank() { //ck acct, balance System.out.printlndrawGraphics("check bank..."); }  public void checkCredit() { //ck score from 3 companiesDraw the graphics here System.out.println("check credit..."); } public void checkLoan() { //ck other loan info System.out.printlndrawGUI("check other loan..."); }  public void checkStock() { //ck how many stock values System.out.println("check stock values..."); }  public void checkIncome() { //ck how much a family make System.out.println("check family income...");Draw the graphical user interface here }
}
</pre>
1
edit