How to make a triangle in java with getX() and getY()?
<p>This is for a homework problem. I'm having a heck of a time trying to create xPoints and yPoints using getX() and getY() please help.</p>

<pre><code>package shapes;

import java.awt.Color;
import java.awt.Graphics;

public class Triangle extends Rectangle {

    //private int[] xPoints = {50, 100, 150};
    //private int[] yPoints = {200, 100, 200};
    private int[] xPoints = {(getX()/2), getX(), (getX()+(getX()/2))};
    private int[] yPoints = {(getY()+getY()), getY(),(getY()+getY())};

    public Triangle(int x, int y, int w, int h, Color lineColor, Color fillColor, boolean fill) {
      super(x, y, w, h, lineColor, fillColor, fill);
    }  

    public void draw(Graphics g) {
        // Be nice. Save the state of the object before changing it.
        Color oldColor = g.getColor();
        if (isFill()) {
            g.setColor(getFillColor());
            g.fillPolygon(xPoints, yPoints, 3);
        }
        g.setColor(getLineColor());
        g.drawPolygon(xPoints, yPoints, 3);
        //g.drawOval(getX(), getY(), getWidth(), getHeight());
        // Set the state back when done.
        g.setColor(oldColor);
    }
    public int getArea() {
      //return area;
      return getWidth()*getHeight();
    }
    /**
    * Returns a String representing this object.
    */
    public String toString() {
        //return "Triangle: \n\tx = " + getX() + "\n\ty = " + getY() + 
               //"\n\tw = " + getWidth() + "\n\th = " + getHeight();
        return "Triangle";
    }
}
</code></pre>

<p>// HERE IS THE SHAPE.JAVA FILE...</p>

<pre><code>package shapes;

import java.awt.Color;
import java.awt.Graphics;

public abstract class Shape {
    private int x, y;//,w,h;
    private Color lineColor;

    public Shape(int x, int y, Color lineColor) {
        this.x = x;
        this.y = y;
        this.lineColor = lineColor;
    }

    public abstract void draw(Graphics g);
    public abstract boolean containsLocation(int x, int y);


    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }


    public Color getLineColor() {
        return lineColor;
    }

    public void setLineColor(Color lineColor) {
        this.lineColor = lineColor;
    }
}
</code></pre>
