Class Square


public class Square extends Rectangle
A mutable class representing a square with integer valued base.
  • Constructor Details

    • Square

      public Square(int base)
      Creates a rectangle of given base and height.
      Parameters:
      base - the base of the rectangle.
  • Method Details

    • base

      public void base(int base)
      Sets the base of the square.
      Overrides:
      base in class Rectangle
      Parameters:
      base - the new base of the square.
      Throws:
      IllegalArgumentException - if base is negative.
    • height

      public void height(int height)
      Sets the height of the square.
      Overrides:
      height in class Rectangle
      Parameters:
      height - the new height of the square.
      Throws:
      IllegalArgumentException - if height is negative.
    • toString

      public String toString()
      Overrides:
      toString in class Rectangle