July 2001
Beginner to intermediate
368 pages
6h 52m
English
Example 10-3 shows how to implement the Abstract Factory objects for this design.
abstract class ResFactory {
abstract public DisplayDriver getDispDrvr();
abstract public PrintDriver getPrtDrvr();
}
class LowResFact extends ResFactory {
public DisplayDriver getDispDrvr() {
return new LRDD();
}
public PrintDriver getPrtDrvr() {
return new LRPD();
}
}
class HighResFact extends ResFactory {
public DisplayDriver getDispDrvr() {
return new HRDD();
}
public PrintDriver getPrtDrvr() {
return new HRPD();
}
}
|
To finish the solution, I have the ApControl talk with the appropriate factory object (either LowResFact or HighResFact); this ...