* #1469 Add Strategy Pattern lambda implementation After Java 8. Also take advantage of enum * #1469 Update class diagrams * #1469 Update README.md Add lambda programmatic example * #1469 Remove unused imports Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
This commit is contained in:
@ -14,6 +14,19 @@ package com.iluwatar.strategy {
|
||||
interface DragonSlayingStrategy {
|
||||
+ execute() {abstract}
|
||||
}
|
||||
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}
|
||||
}
|
||||
class MeleeStrategy {
|
||||
- LOGGER : Logger {static}
|
||||
+ MeleeStrategy()
|
||||
@ -30,7 +43,10 @@ package com.iluwatar.strategy {
|
||||
+ execute()
|
||||
}
|
||||
}
|
||||
Strategy ..+ LambdaStrategy
|
||||
Strategy --> "-dragonSlayingStrategy" DragonSlayingStrategy
|
||||
DragonSlayer --> "-strategy" DragonSlayingStrategy
|
||||
Strategy ..|> DragonSlayingStrategy
|
||||
MeleeStrategy ..|> DragonSlayingStrategy
|
||||
ProjectileStrategy ..|> DragonSlayingStrategy
|
||||
SpellStrategy ..|> DragonSlayingStrategy
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 140 KiB |
Reference in New Issue
Block a user