Line.java

package com.bozoid.cis370.hw02;


/**
A simple <code>Line</code> class for homework #2.

@author Walt Leipold
*/
public class Line extends Shape
{
    /**
    Construct a <code>Line</code> object.

    @param x1 x-coordinate of first endpoint
    @param y1 y-coordinate of first endpoint
    @param x2 x-coordinate of second endpoint
    @param y2 y-coordinate of second endpoint
    */
    public Line(double x1,double y1,double x2,double y2)
    {
        super(x1,y1);
        this.x2 = x2;
        this.y2 = y2;
    }


    /** 
    @return the x-coord of the 'other' endpoint of the 
    <code>Line</code> (The x-coord of the first endpoint can be 
    obtained by calling <code>getX()</code>.)
    */
    public double getEndX()
    {
        return x2;
    }


    /** 
    @return the y-coord of the 'other' endpoint of the 
    <code>Line</code> (The y-coord of the first endpoint can be 
    obtained by calling <code>getY()</code>.)
    */
    public double getEndY()
    {
        return y2;
    }


    /**
    @return a <code>String</code> describing this <code>Line</code>
    */
    public String toString()
    {
        return getClass().getName() + "[" +
            "x1=" + formatNum(getX()) + "," +
            "y1=" + formatNum(getY()) + "," +
            "x2=" + formatNum(x2) + "," +
            "y2=" + formatNum(y2) + "]";
    }


    private double x2,y2;
}