Question: If the solution and explanation could be posted as an image that would be preferred. 5. Write three classes WaterBody, River, and StillWater as follows:

If the solution and explanation could be posted as an image that would be preferred.
5. Write three classes WaterBody, River, and StillWater as follows: First, each class must have a public constructor that stores its parameters, where your code may have arbitrary behaviour if a parameter is null: Moreover, each class must provide the following instance methods in its public interface, where none of the methods have any explicit parameters: Brevity, minimal repetition of code, and use of inheritance are important for marking. Provide full implementations of the three classes and their methods. For each of the three classes, do not provide methods or constructors other than those listed above. Use the annotation @0verride for your methods whenever this is possible. The code fragment StillWater sea = new StillWater("North Sea", false); River r1 = new River("Thames", sea); River r2 = new River("Lea", r1); System.out.println(r2); System.out.println(r1.hasFreshWater()); System.out.println(sea.hasFreshWater()); should have the following output with your implementation: Lea, which flows into Thames, which flows into North Sea, with non-fresh water true false
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
