| 
									
										
										
										
											2016-08-30 13:29:12 +02:00
										 |  |  | @startuml | 
					
						
							|  |  |  | package com.iluwatar.semaphore { | 
					
						
							|  |  |  |   class Fruit { | 
					
						
							|  |  |  |     - type : FruitType | 
					
						
							|  |  |  |     + Fruit(type : FruitType) | 
					
						
							|  |  |  |     + getType() : FruitType | 
					
						
							|  |  |  |     + toString() : String | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   class App { | 
					
						
							|  |  |  |     + App() | 
					
						
							|  |  |  |     + main(args : String[]) {static} | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   class Semaphore { | 
					
						
							|  |  |  |     - counter : int | 
					
						
							|  |  |  |     - licenses : int | 
					
						
							|  |  |  |     + Semaphore(licenses : int) | 
					
						
							|  |  |  |     + acquire() | 
					
						
							|  |  |  |     + getAvailableLicenses() : int | 
					
						
							|  |  |  |     + getNumLicenses() : int | 
					
						
							|  |  |  |     + release() | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-09-18 17:51:09 +03:00
										 |  |  |   class FruitShop { | 
					
						
							|  |  |  |     - available : boolean[] | 
					
						
							|  |  |  |     - bowls : FruitBowl[] | 
					
						
							|  |  |  |     - semaphore : Semaphore | 
					
						
							|  |  |  |     + FruitShop() | 
					
						
							|  |  |  |     + countFruit() : int | 
					
						
							|  |  |  |     + returnBowl(bowl : FruitBowl) | 
					
						
							|  |  |  |     + takeBowl() : FruitBowl | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   interface Lock { | 
					
						
							|  |  |  |     + acquire() {abstract} | 
					
						
							|  |  |  |     + release() {abstract} | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   class FruitBowl { | 
					
						
							|  |  |  |     - fruit : ArrayList<Fruit> | 
					
						
							|  |  |  |     + FruitBowl() | 
					
						
							|  |  |  |     + countFruit() : int | 
					
						
							|  |  |  |     + put(f : Fruit) | 
					
						
							|  |  |  |     + take() : Fruit | 
					
						
							|  |  |  |     + toString() : String | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-08-30 13:29:12 +02:00
										 |  |  |   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 |