Hi! I've just finished writing a program, and I keep getting an error stating
Shapes.java:308: cannot find symbol
symbol : class ATriangle
location: class Shapes
ATriangle ATriangle = new ATriangle(1.0, 2.0, 5.0);
My program is about superclasses and subclasses, so each new class I make extends the main one (which is AnObject).
ATriangle, the third subclass, isn't working when I create a new one (giving the error shown above) It looks like this:
class ATriangle extends AnObject { double Side1; double Side2; double Side3; //No parameter constructor public ATriangle() { double Side1; double Side2; double Side3; } // 3 parameter constructor public ATriangle(double s1, double s2, double s3) { Side1 = s1; Side2 = s2; Side3 = s3; } // 5 parameter constructor public ATriangle(double s1, double s2, double s3, String Colour1, String Filled1) { Side1 = s1; Side2 = s2; Side3 = s3; Colour = Colour1; Filled = Filled1; } //Accessor and mutator methods for each attribute public double getSide1() { return Side1; } public double getSide2() { return Side2; } public double getSide3() { return Side3; } public void setSide1(double s1) { Side1 = s1; } public void setSide2(double s2) { Side2 = s2; } public void setSide3(double s3) { Side3 = s3; } //AREA ACCESSOR public double getArea() { double s = (Side1 + Side2 + Side3) / 2; double Area = Math.sqrt( s*(s - Side1)*(s - Side2)*(s - Side3) ); return Area; } public double getPerimeter() { double Perimeter = Side1 + Side2 + Side3; return Perimeter; } //TOSTRING METHOD public String toString() { return "\n" + "Side1 : " + Side1 + "\n" + "Side2 : " + Side2 + "\n" + "Side3 : " + Side3; } }
An my main class is:
public class Shapes { public static void main (String[] args) { //Test AnObject: System.out.println("TESTING THE SUPERCLASS (OBJECT) : " + "\n"); AnObject object = new AnObject("Green", "Filled"); System.out.println(object.getColour()); System.out.println(object.getFilled()); object.setColour("Blue"); object.setFilled("Not Filled"); System.out.println(object.toString() + "\n"); //Test ACircle System.out.println("TESTING THE CIRCLE! : " + "\n"); ACircle circle = new ACircle("Yellow", "Not Filled", 4.0); circle.setRadius(5.0); System.out.println(circle.getRadius()); System.out.println("Area : " + circle.getArea()); System.out.println("Perimeter : " +circle.getPerimeter()); System.out.println("Diameter : " +circle.getDiameter()); System.out.println(circle.toString() + "\n"); //Test ARectangle System.out.println("TESTING THE RECTANGLE! : " + "\n"); ARectangle rectangle = new ARectangle(5.0, 3.0, "Red", "Filled"); System.out.println("Width : " + rectangle.getWidth()); System.out.println("Length: " + rectangle.getLength()); rectangle.setWidth(10.0); rectangle.setLength(2.0); System.out.println("Area : " + rectangle.getArea()); System.out.println("Perimeter: " + rectangle.getPerimeter()); System.out.println(rectangle.toString()); //Test ATriangle System.out.println("TESTING THE ATRIANGLE! : " + "\n"); ATriangle triangle = new ATriangle(1.0, 2.0, 5.0); } }
Can anyone see why this isn't working?
--- Update ---
Also, I think it's important to not that both ARectangle and ACircle have ARectangle.class and ACircle.class when I search it under my finder, but ATriangle does not.