-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
44 lines (36 loc) · 1.11 KB
/
Main.java
File metadata and controls
44 lines (36 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import factory.GUIFactory;
import factory.MacOSFactory;
import factory.WindowsFactory;
import java.util.Scanner;
public class Main {
private static GUIFactory macOSFactory = new MacOSFactory();
private static GUIFactory windowsFactory = new WindowsFactory();
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String osKorean = scanner.nextLine();
GUIFactory guiFactory = getOS(osKorean);
if (!validOS(guiFactory)) {
return;
}
App app = new App(guiFactory);
app.paint();
scanner.close();
}
private static boolean validOS(GUIFactory guiFactory) {
if (guiFactory == null) {
System.out.println("그런 OS는 존재하지 않습니다.");
return false;
}
return true;
}
private static GUIFactory getOS(String osKorean) {
switch (osKorean) {
case "맥":
return macOSFactory;
case "윈도우":
return windowsFactory;
default:
return null;
}
}
}