Softwaredesign: Beispiel 2: Schablonenmethode |
public class Pager {
public final
String [] [] format(String [] lines) {
String [] header = formatHeader();
String [] footer = formatFooter();
String [] [] pages;
for (String l : lines) {
// ...;
}
return pages;
}
private
String [] defaultHeader = {};
private
String [] defaultFooter = {};
String [] formatHeader() {
return defaultHeader;
}
String [] formatFooter() {
return defaultFooter;
}
}
|
public class PagerWithDeco
extends Pager {
String [] header = { "header line 1",
"header line 2"
};
String [] footer = { "footer line 1",
"footer line 2"
};
String [] formatHeader() {
return header;
}
String [] formatFooter() {
return footer;
}
}
|
Letzte Änderung: 13.04.2012 | © Prof. Dr. Uwe Schmidt |