title: Constructor ... is not applicable (actual and formal argument lists differ in length) - but it does match
body: <p>So i'm doing an assignment for school in java... It's a class hierarchy kind of assignment and we are supposed to make a "Triangle.java" class that extends a "ClosedShape.java" class which extends a "Shape.java" .... the ClosedShape and Shape are both given to us, so most likely nothing wrong with them (i'll post them anyway) but my Triangle class is as follows:</p>
  
  <pre><code>    public abstract class Triangle extends ClosedShape{
  
          public Triangle(int[] a, int[] b, int base, int height){
              super(true, 3, a, b);
              setWidth(base);
              setHeight(height);
              setXYCoords(a, b);
          }
  
           public Triangle(int x, int y, int base, int height){
              int[] a = new int[3];
              int[] b = new int[3];
  
              a[0] = x;
              a[1] = (x+base)/2;
              a[2] = (x+base);
  
              b[0] = y;
              b[1] = (y+height)/2;
              b[2] = (y+height);
           }
  
  }
  </code></pre>
  
  <p>The reason I have two constructors is because i need to create those two arrays to hold the points for drawing the shape...and then I need to have them passed into the ClosedShape(boolean, int, int[], int[]) super class... if i create the arrays in the same constructor they would need to be defined before the call to super() so they could be passed in, but that's not allowed because the call to super() must be first...so currently, when I try to compile Triangle.java i get the error:</p>
  
  <pre><code>Triangle.java.14: error: no suitable constructor found for ClosedShape()
    { //little arrow pointing under the '{'
  
  constructor ClosedShape.ClosedShape(boolean, int, int[], int[]) is not applicable
      (actual and formal argument lists differ in length)      
      constructor ClosedShape.ClosedShape(boolean, int) is not applicable
      (actual and formal argument lists differ in length)
  1 error
  </code></pre>
  
  <p>It also specifies in the assignment that the signature for the triangle <strong>must</strong> be Traingle(int x, int y, int base, int height)... So....i'm confused because if i'm not mistaken (which java believes i am...) I made a super call with all the proper values, and there <em>is</em> a constructor "ClosedShape(boolean, int, int[], int[])"... heres the ClosedShape class:</p>
  
  <pre><code>    import java.awt.Graphics;
  
  public abstract class ClosedShape extends Shape {
      boolean polygon;
      int numPoints;
      int[] xVertices;
      int[] yVertices;
      int x,y,width, height;
  
      public ClosedShape(boolean isPolygon, int numPoints) {
          super(0,0);
          this.polygon = isPolygon;
          this.numPoints = numPoints;
      }
  
      public ClosedShape(boolean isPolygon, int numPoints, int[] x, int[] y) {
          super(x[0],y[0]);
          this.polygon = isPolygon;
          if (isPolygon) {
              this.numPoints = numPoints;
              xVertices = new int[numPoints]; // error check?  if x.length == numPoints
              //for (int i = 0; i &lt; x.length; i++) { // make copy of array: why?
              //  xVertices[i] = x[i];
              //}
              yVertices = new int[numPoints]; // error check?  if y.length == numPoints
              for (int i = 0; i &lt; y.length; i++) { // make copy of array
                      yVertices[i] = y[i];
              }
          }
          else { // its an oval - define bounding box
              this.numPoints = 4;
              this.x = x[0];
              this.y = y[0];
              width = x[1];
              height = y[1];
          }
      }
  
      public void setXYCoords(int[] x, int[] y){
          this.xVertices = x;
          this.yVertices = y;
      }
  
      // Gives access to the width attribute
      public void setWidth(int width){
          this.width = width;
      }
  
      // Gives access to the height attribute
      public void setHeight(int height) {
          this.height = height;
      }
  
      public void draw(Graphics g) {
          if (polygon) {
              g.drawPolygon(xVertices, yVertices, numPoints);
          }
          else {
              g.drawOval(x, y, width, height);
          }
  
      }
  
      public abstract double Area();
      public abstract double Perimeter();
  
  
  
  
  
  
  
  
  }
  </code></pre>