Add creational patterns, Interpreter; remove scripts; update README
This commit is contained in:
22
01-creational/abstract-factory/Main.java
Normal file
22
01-creational/abstract-factory/Main.java
Normal file
@@ -0,0 +1,22 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user