Let's create Plane and Helicopter classes that implement the CanFly interface. Then in the Solution class's static method, we need to read a String from the console. If it's equal to "helicopter" ("plane"), we'll assign a Helicopter (Plane) object to the static CanFly field result. In the static block, initialize the CanFly field result by calling the reset method.
Mastering the static block
- 8
Locked
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Adam Odoj
25 July 2022, 23:00
I wrote it with switch statement instead of "if-else" as suggested.
Looks cleaner then the suggested version and just passed a test!
0