forked from iluwatar/java-design-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflyweight.urm.puml
More file actions
66 lines (66 loc) · 1.43 KB
/
flyweight.urm.puml
File metadata and controls
66 lines (66 loc) · 1.43 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@startuml
package com.iluwatar.flyweight {
class AlchemistShop {
- LOGGER : Logger {static}
- bottomShelf : List<Potion>
- topShelf : List<Potion>
+ AlchemistShop()
+ enumerate()
- fillShelves()
+ getBottomShelf() : List<Potion>
+ getTopShelf() : List<Potion>
}
class App {
+ App()
+ main(args : String[]) {static}
}
class HealingPotion {
- LOGGER : Logger {static}
+ HealingPotion()
+ drink()
}
class HolyWaterPotion {
- LOGGER : Logger {static}
+ HolyWaterPotion()
+ drink()
}
class InvisibilityPotion {
- LOGGER : Logger {static}
+ InvisibilityPotion()
+ drink()
}
class PoisonPotion {
- LOGGER : Logger {static}
+ PoisonPotion()
+ drink()
}
interface Potion {
+ drink() {abstract}
}
class PotionFactory {
- potions : Map<PotionType, Potion>
+ PotionFactory()
~ createPotion(type : PotionType) : Potion
}
enum PotionType {
+ HEALING {static}
+ HOLY_WATER {static}
+ INVISIBILITY {static}
+ POISON {static}
+ STRENGTH {static}
+ valueOf(name : String) : PotionType {static}
+ values() : PotionType[] {static}
}
class StrengthPotion {
- LOGGER : Logger {static}
+ StrengthPotion()
+ drink()
}
}
AlchemistShop --> "-topShelf" Potion
HealingPotion ..|> Potion
HolyWaterPotion ..|> Potion
InvisibilityPotion ..|> Potion
PoisonPotion ..|> Potion
StrengthPotion ..|> Potion
@enduml