Assume the existence of a Window class with a method getClientAreaHeight that returns an integer representing the height of the portion of the window that an application program can use for its display. Assume also, a subclass BorderedWindow with an integer instance variable borderSize, that represents the size of the border around the window. Override the getClientAreaHeight in BorderWindow to return the client area height as returned by the superclass minus the border size (taking into account top and bottom borders).

Assume the existence of a Window class with a method getClientAreaHeight that returns an integer representing the height of the portion of the window that an application program can use for its display. Assume also, a subclass BorderedWindow with an integer  instance variable  borderSize, that represents the size of the border around the window. Override the getClientAreaHeight in BorderWindow to return the client area height as returned by the superclass minus the border size (taking into account top and bottom borders).

LANGUAGE: JAVA

CHALLENGE:

Assume the existence of a Window class with a method getClientAreaHeight that returns an integer representing the height of the portion of the window that an application program can use for its display. Assume also, a subclass BorderedWindow with an integer instance variable borderSize, that represents the size of the border around the window. Override the getClientAreaHeight in BorderWindow to return the client area height as returned by the superclass minus the border size (taking into account top and bottom borders).

SOLUTION:

public int getClientAreaHeight() {
   return super.getClientAreaHeight() - 2 * borderSize;
}

Add comment