Package doodlepad

Class Rectangle

java.lang.Object
doodlepad.Shape
doodlepad.Rectangle

public class Rectangle extends Shape
A class that implements a graphical rectangle object
  • Constructor Details

    • Rectangle

      public Rectangle(double x, double y, double width, double height)
      Constructor for the Rectangle object.
      Parameters:
      x - The x-coordinate of the upper left-hand corner of the Rectangle object.
      y - The y-coordinate of the upper left-hand corner of the Rectangle object.
      width - The width of the Rectangle object.
      height - The height of the Rectangle object.
    • Rectangle

      public Rectangle(double x, double y, double width, double height, Layer layer)
      Constructor for the Rectangle object.
      Parameters:
      x - The x-coordinate of the upper left-hand corner of the Rectangle object.
      y - The y-coordinate of the upper left-hand corner of the Rectangle object.
      width - The width of the Rectangle object.
      height - The height of the Rectangle object.
      layer - The Layer object to which the Oval should be added, or null if not to add to a Layer.
    • Rectangle

      public Rectangle()
      Default constructor for the Rectangle object. Creates a new 100x100 draggable shape and positions it randomly.
  • Method Details

    • draw

      public void draw(Graphics2D g)
      Draw the Rectangle
      Specified by:
      draw in class Shape
      Parameters:
      g - The Graphics2D object on which to draw the Rectangle
    • toString

      public String toString()
      Generate a representation of the Rectangle object
      Overrides:
      toString in class Shape
      Returns:
      String representation