1
+ @startuml
2
+ package com . iluwatar . abstractfactory {
3
+ class App {
4
+ - LOGGER : Logger {static}
5
+ - army : Army
6
+ - castle : Castle
7
+ - king : King
8
+ + App ()
9
+ + createKingdom(factory : KingdomFactory)
10
+ + getArmy () : Army
11
+ ~ getArmy(factory : KingdomFactory) : Army
12
+ + getCastle () : Castle
13
+ ~ getCastle(factory : KingdomFactory) : Castle
14
+ + getKing () : King
15
+ ~ getKing(factory : KingdomFactory) : King
16
+ + main(args : String[]) {static}
17
+ - setArmy(army : Army)
18
+ - setCastle(castle : Castle)
19
+ - setKing(king : King)
20
+ }
21
+ class FactoryMaker {
22
+ + FactoryMaker ()
23
+ + makeFactory(type : KingdomType) : KingdomFactory {static}
24
+ }
25
+ enum KingdomType {
26
+ + ELF {static}
27
+ + ORC {static}
28
+ + valueOf(name : String) : KingdomType {static}
29
+ + values() : KingdomType[] {static}
30
+ }
31
+ interface Army {
32
+ + getDescription () : String {abstract }
33
+ }
34
+ interface Castle {
35
+ + getDescription () : String {abstract }
36
+ }
37
+ class ElfArmy {
38
+ ~ DESCRIPTION : String {static}
39
+ + ElfArmy ()
40
+ + getDescription () : String
41
+ }
42
+ class ElfCastle {
43
+ ~ DESCRIPTION : String {static}
44
+ + ElfCastle ()
45
+ + getDescription () : String
46
+ }
47
+ class ElfKing {
48
+ ~ DESCRIPTION : String {static}
49
+ + ElfKing ()
50
+ + getDescription () : String
51
+ }
52
+ class ElfKingdomFactory {
53
+ + ElfKingdomFactory ()
54
+ + createArmy () : Army
55
+ + createCastle () : Castle
56
+ + createKing () : King
57
+ }
58
+ interface King {
59
+ + getDescription () : String {abstract }
60
+ }
61
+ interface KingdomFactory {
62
+ + createArmy () : Army {abstract }
63
+ + createCastle () : Castle {abstract }
64
+ + createKing () : King {abstract }
65
+ }
66
+ class OrcArmy {
67
+ ~ DESCRIPTION : String {static}
68
+ + OrcArmy ()
69
+ + getDescription () : String
70
+ }
71
+ class OrcCastle {
72
+ ~ DESCRIPTION : String {static}
73
+ + OrcCastle ()
74
+ + getDescription () : String
75
+ }
76
+ class OrcKing {
77
+ ~ DESCRIPTION : String {static}
78
+ + OrcKing ()
79
+ + getDescription () : String
80
+ }
81
+ class OrcKingdomFactory {
82
+ + OrcKingdomFactory ()
83
+ + createArmy () : Army
84
+ + createCastle () : Castle
85
+ + createKing () : King
86
+ }
87
+ }
88
+ KingdomType ..+ FactoryMaker
89
+ App --> "- castle " Castle
90
+ FactoryMaker ..+ App
91
+ App --> "- king " King
92
+ App --> "- army " Army
93
+ ElfArmy ..|> Army
94
+ ElfCastle ..|> Castle
95
+ ElfKing ..|> King
96
+ ElfKingdomFactory ..|> KingdomFactory
97
+ OrcArmy ..|> Army
98
+ OrcCastle ..|> Castle
99
+ OrcKing ..|> King
100
+ OrcKingdomFactory ..|> KingdomFactory
101
+ @enduml
0 commit comments