mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-05 12:14:18 +00:00
Use enums instead os switch blocks
Its better to use enums instead of switch blocks which makes the code longer and difficult to maintain as and when new state appears.
This commit is contained in:
1 parent
cd20e7a3f4
commit
0c83ccc2fe
12 files changed
+56
-130
No files matched your search
@@ -33,7 +33,9 @@ package com.iluwatar.observer {
|
||||
+ RAINY {static}
|
||||
+ SUNNY {static}
|
||||
+ WINDY {static}
|
||||
+ description String
|
||||
+ toString() : String
|
||||
+ getDescription() : String
|
||||
+ valueOf(name : String) : WeatherType {static}
|
||||
+ values() : WeatherType[] {static}
|
||||
}
|
||||
@@ -71,10 +73,10 @@ package com.iluwatar.observer.generic {
|
||||
Weather --> "-currentWeather" WeatherType
|
||||
GWeather --> "-currentWeather" WeatherType
|
||||
Weather --> "-observers" WeatherObserver
|
||||
Hobbits ..|> WeatherObserver
|
||||
Orcs ..|> WeatherObserver
|
||||
GHobbits ..|> Race
|
||||
GOrcs ..|> Race
|
||||
GWeather --|> Observable
|
||||
Race --|> Observer
|
||||
@enduml
|
||||
Hobbits ..|> WeatherObserver
|
||||
Orcs ..|> WeatherObserver
|
||||
GHobbits ..|> Race
|
||||
GOrcs ..|> Race
|
||||
GWeather --|> Observable
|
||||
Race --|> Observer
|
||||
@enduml
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
Reference in new issue
Block a user