Refactoring Rectangle

  • 13
  • Locked
In the Rectangle class: 1. Change the getHeight and getWidth methods so that they return HasHeight and HasWidth objects, respectively. 2. To do this, inside the getHeight and getWidth methods, create local classes that implement the interfaces.
You can't complete this task, because you're not signed in.
Comments (2)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Justin Smith
Level 38 , Greenfield, USA, United States
13 January 2022, 13:59
This task is a good illustration of how deep the nesting can go. You end up with a method inside a class inside a method inside a class. Is there a limit to how much nesting is possible?
Jurij Thmsn
Level 29 , Flensburg, Germany
22 October 2021, 13:33
Confusing task . Don't forget to change the return types of the static methods:
public static double getHeight(HasHeight rectangle) {return rectangle.getHeight();}