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:
Rakesh Venkatesh
2020-08-05 15:50:05 +02:00
parent cd20e7a3f4
commit 0c83ccc2fe
12 changed files with 56 additions and 130 deletions

View File

@ -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