23 lines
746 B
Java
23 lines
746 B
Java
package abstractfactory;
|
|
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
System.out.println("=== Abstract Factory Pattern Demo ===\n");
|
|
|
|
String os = System.getProperty("os.name", "Windows").toLowerCase();
|
|
GUIFactory factory = os.contains("mac") ? new MacFactory() : new WindowsFactory();
|
|
|
|
System.out.println("Detected OS family: " + (os.contains("mac") ? "Mac" : "Windows"));
|
|
System.out.println();
|
|
|
|
Application app = new Application(factory);
|
|
app.render();
|
|
app.simulateClick();
|
|
|
|
System.out.println("\n--- Forcing Mac UI ---");
|
|
Application macApp = new Application(new MacFactory());
|
|
macApp.render();
|
|
macApp.simulateClick();
|
|
}
|
|
}
|