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:
@ -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
|
||||
|
BIN
observer/etc/observer_with_generics.png
Normal file
BIN
observer/etc/observer_with_generics.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 102 KiB |
Reference in New Issue
Block a user