| 
									
										
										
										
											2019-12-07 18:03:49 +02:00
										 |  |  | @startuml | 
					
						
							|  |  |  | package com.iluwatar.strategy { | 
					
						
							|  |  |  |   class App { | 
					
						
							|  |  |  |     - LOGGER : Logger {static} | 
					
						
							|  |  |  |     + App() | 
					
						
							|  |  |  |     + main(args : String[]) {static} | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   class DragonSlayer { | 
					
						
							|  |  |  |     - strategy : DragonSlayingStrategy | 
					
						
							|  |  |  |     + DragonSlayer(strategy : DragonSlayingStrategy) | 
					
						
							|  |  |  |     + changeStrategy(strategy : DragonSlayingStrategy) | 
					
						
							|  |  |  |     + goToBattle() | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   interface DragonSlayingStrategy { | 
					
						
							|  |  |  |     + execute() {abstract} | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-01-19 14:36:26 +08:00
										 |  |  |   class LambdaStrategy { | 
					
						
							|  |  |  |     - LOGGER : Logger {static} | 
					
						
							|  |  |  |     + LambdaStrategy() | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   enum Strategy { | 
					
						
							|  |  |  |     + MeleeStrategy {static} | 
					
						
							|  |  |  |     + ProjectileStrategy {static} | 
					
						
							|  |  |  |     + SpellStrategy {static} | 
					
						
							|  |  |  |     - dragonSlayingStrategy : DragonSlayingStrategy | 
					
						
							|  |  |  |     + execute() | 
					
						
							|  |  |  |     + valueOf(name : String) : Strategy {static} | 
					
						
							|  |  |  |     + values() : Strategy[] {static} | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-12-07 18:03:49 +02:00
										 |  |  |   class MeleeStrategy { | 
					
						
							|  |  |  |     - LOGGER : Logger {static} | 
					
						
							|  |  |  |     + MeleeStrategy() | 
					
						
							|  |  |  |     + execute() | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   class ProjectileStrategy { | 
					
						
							|  |  |  |     - LOGGER : Logger {static} | 
					
						
							|  |  |  |     + ProjectileStrategy() | 
					
						
							|  |  |  |     + execute() | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   class SpellStrategy { | 
					
						
							|  |  |  |     - LOGGER : Logger {static} | 
					
						
							|  |  |  |     + SpellStrategy() | 
					
						
							|  |  |  |     + execute() | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-01-19 14:36:26 +08:00
										 |  |  | Strategy ..+ LambdaStrategy | 
					
						
							|  |  |  | Strategy -->  "-dragonSlayingStrategy" DragonSlayingStrategy | 
					
						
							| 
									
										
										
										
											2019-12-07 18:03:49 +02:00
										 |  |  | DragonSlayer -->  "-strategy" DragonSlayingStrategy | 
					
						
							| 
									
										
										
										
											2021-01-19 14:36:26 +08:00
										 |  |  | Strategy ..|> DragonSlayingStrategy  | 
					
						
							| 
									
										
										
										
											2019-12-07 18:03:49 +02:00
										 |  |  | MeleeStrategy ..|> DragonSlayingStrategy  | 
					
						
							|  |  |  | ProjectileStrategy ..|> DragonSlayingStrategy  | 
					
						
							|  |  |  | SpellStrategy ..|> DragonSlayingStrategy  | 
					
						
							|  |  |  | @enduml |