package rectangle; // package groups related classes together

/**
 * <p>Title: Rectangle </p>
 * <p>Description:  Represents a geometric rectangle</p>
 */
public class Rectangle { // a class is a blueprint for creating an object
  //attributes hold the state or data of an object
  private double length;  //attribute holding length of the rectangle
  private double width;   //attribute holding width of the rectangle

  // The constructor initializes an object after it has been created
  public Rectangle(double len, double wid) {//initialize EVERY attribute
    length = len;
    width = wid;
  }

  // Methods define the behavior of the object--------------------------
  public double getArea( ) { // accessor method: doesn't change object's data
    return length*width;
  }

  public double getLength(){ // accessor method: doesn't change object's data
    return length;
  }

  public double getPerimeter(){ // accessor method: doesn't change object's data
    return 2*(length + width);
  }

  public double getWidth() { // accessor method - doesn't change object's data
    return width;
  }

  public String toString() { // accessor method - doesn't change object's data
    return "Rectangle: length=" + length + ", width=" + width;
  }
}


