Class Rectangle

java.lang.Object
it.unimi.di.prog2.e17.Rectangle
Direct Known Subclasses:
Square

public class Rectangle extends Object
A mutable class representing a rectangle with integer valued base and height.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rectangle(int base, int height)
    Creates a rectangle of given base and height.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the base of the rectangle.
    void
    base(int base)
    Sets the base of the rectangle.
    int
    Returns the height of the rectangle.
    void
    height(int height)
    Sets the height of the rectangle.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Rectangle

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

    • base

      public int base()
      Returns the base of the rectangle.
      Returns:
      the base of the rectangle.
    • base

      public void base(int base)
      Sets the base of the rectangle.
      Parameters:
      base - the new base of the rectangle.
    • height

      public int height()
      Returns the height of the rectangle.
      Returns:
      the height of the rectangle.
    • height

      public void height(int height)
      Sets the height of the rectangle.
      Parameters:
      height - the new height of the rectangle.
    • toString

      public String toString()
      Overrides:
      toString in class Object