forked from iluwatar/java-design-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsemaphore.urm.puml
More file actions
58 lines (58 loc) · 1.22 KB
/
semaphore.urm.puml
File metadata and controls
58 lines (58 loc) · 1.22 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
@startuml
package com.iluwatar.semaphore {
class FruitShop {
- available : boolean[]
- bowls : FruitBowl[]
- semaphore : Semaphore
+ FruitShop()
+ countFruit() : int
+ returnBowl(bowl : FruitBowl)
+ takeBowl() : FruitBowl
}
class FruitBowl {
- fruit : ArrayList<Fruit>
+ FruitBowl()
+ countFruit() : int
+ put(f : Fruit)
+ take() : Fruit
+ toString() : String
}
class Fruit {
- type : FruitType
+ Fruit(type : FruitType)
+ getType() : FruitType
+ toString() : String
}
interface Lock {
+ acquire() {abstract}
+ release() {abstract}
}
class App {
+ App()
+ main(args : String[]) {static}
}
class Semaphore {
- counter : int
- licenses : int
+ Semaphore(licenses : int)
+ acquire()
+ getAvailableLicenses() : int
+ getNumLicenses() : int
+ release()
}
enum FruitType {
+ APPLE {static}
+ LEMON {static}
+ ORANGE {static}
+ valueOf(name : String) : FruitType {static}
+ values() : FruitType[] {static}
}
}
FruitShop --+ Fruit
Fruit --> "-type" FruitType
FruitType ..+ Fruit
FruitBowl --+ Fruit
FruitBowl --> "-fruit" Fruit
FruitShop --> "-semaphore" Semaphore
Semaphore ..|> Lock
@enduml