You are given a class Rectangle that produces “ASCII art” rectangles such as the following:

+-------------+
|             |
|             |
|             |
|             |
|             |
+-------------+

The code is given below.

Your task is to produce a subclass FilledRectangle that produces figures such as

+-------------+
|#############|
|#############|
|#############|
|#############|
|#############|
+-------------+

(when the fill character is #).

Complete the following file:

FilledRectangle.java

/* TODO: Complete the class definition. Supply the body of the constructor and any instance fields. */ /** A rectangle whose interior is filled with a pattern obtained by repeating a character. */ public class FilledRectangle ... { /** Constructs a rectangle with a given width, height, and fill @param aWidth the width (including the corners) @param aHeight the height (including the corners) @param aFill the fill character */ public FilledRectangle(int aWidth, int aHeight, char aFill) { ... } /** Prints one line of the rectangle. @param i the line to print (1 <= i <= height) */ public void printLine(int i) { if (i == 1 || i == getHeight()) printHelper('+', '-'); else printHelper('|', fill); } ... // The following method tests your class public static void main(String[] args) { FilledRectangle fr = new FilledRectangle(10, 7, '*'); fr.print(); } }

Use the following file:

Rectangle.java

/**
   A rectangle that is printed using "ASCII art".
*/
public class Rectangle
{
   private int width;
   private int height;

   /**
      Constructs a rectangle with a given width and height.
      @param aWidth the width (including the corners)
      @param aHeight the height (including the corners)
   */
   public Rectangle(int aWidth, int aHeight)
   {
      width = aWidth;
      height = aHeight;
   }

   /**
      Gets the width of this rectangle.
      @return the width
   */
   public int getWidth()
   {
      return width;
   }

   /**
      Gets the height of this rectangle.
      @return the height
   */
   public int getHeight()
   {
      return height;
   }

   /**
      Prints the rectangle.
   */
   public void print()
   {
      for (int i = 1; i <= height; i++)
      {
         printLine(i);         
      }
   }

   /**
      Prints one line of the rectangle.
      @param i the line to print (1 <= i <= height)
   */
   public void printLine(int i)
   {
      if (i == 1 || i == height)
         printHelper('+', '-');
      else
         printHelper('|', ' ');
   }

   /**
      Prints one line of the rectangle.
      @param boundary the character to be used at the left and
      right boundary
      @param middle the character to be used elsewhere
   */
   public void printHelper(char boundary, char middle)
   {
      System.out.print(boundary);
      for (int j = 2; j < width; j++)
         System.out.print(middle);
      System.out.println(boundary);
   }
}