/**
 * Segment.java
 * 
 * Shows how a Segment class can be built by inheritance.
 * @author Scot Drysdale on 4/27/00.
 */

import java.awt.*;

public class Segment extends GeomShape {
  private int x_1, y_1, x_2, y_2; // Segment endpoints

  /**
   * Constructor for Segment. Called to create a segment object with endpoints
   * (x1, y1) and (x2, y2), with color segmentColor.
   * 
   * @param x1 x coordinate of point 1
   * @param y1 y coordinate of point 1
   * @param x2 x coordinate of point 2
   * @param y2 y coordinate of point 2
   * @param segmentColor the color of the segment
   */
  public Segment(int x1, int y1, int x2, int y2, Color segmentColor) {
    super(segmentColor);
    x_1 = x1;
    x_2 = x2;
    y_1 = y1;
    y_2 = y2;
  }

  /**
   *  Have the Segment object draw itself on the page passed as a parameter.
   *  Assumes that the Graphics object's color has already been set.
   *  @page the graphics page on which to draw.
   */
  protected void drawShape(Graphics page) {
    page.drawLine(x_1, y_1, x_2, y_2);
  }

  /**
   * Move the Segment by deltaX in x and deltaY in y.
   * deltaX the change in the x values
   * deltaY the change in the y values
   */
  public void move(int deltaX, int deltaY) {
    x_1 += deltaX;
    x_2 += deltaX;
    y_1 += deltaY;
    y_2 += deltaY;
  }

  /**
   * A segment has no area.
   * @return the area of the segment
   */
  public double areaOf() {
    return 0.0;
  }
}