I cant figure out how to fix the "public class Triangle implements Measurable"
i dont know what i am doing wrong to get this error.. i am not fluent in java but i never had this error before. i tried changing the name but in the process i get more errors. if any one can help Thank you very much.

public class Triangle {

	/** Sean Bing
	 */

	

		double side1 = 0;

		double side2 = 0;

		double side3 = 0;

		double s = (side1 + side2 + side3) / 2;

		double area = Math.sqrt (s * (s - side1) * (s - side2) * (s - side3));
		
	
	public interface Measurable {
		public double getPerimeter();
		public double getArea();
	
	}
	

	public class Triangle implements Measurable // error at Triangle- can't have 
												// the same name as parent file

	{

		private double mySide1;

		private double mySide2;

		private double mySide3;

		public Triangle(double Side1, double Side2, double Side3)

		{
			mySide1 = side1;

			mySide2 = side2;

			mySide3 = side3;
		}

		public double getPerimeter()

		{
			return s = (side1 + side2 + side3) / 2;

		}

		public double getArea()

		{

			return area = Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
		}

		public class RightTriangle extends Triangle {

			public class RightTriangle {
			}
		}

	}

}

Recommended Answers

All 4 Replies

You have

public class Triangle {

and
public class Triangle implements Measurable
but you can't have 2 classes with the same name in the same file
ps Next time please post your code correctly indented and between CODE tags so we can read it properly.

I am new to this.. What do you mean by code correctly indented and between CODE tags

OK. When you post code use indentation to make the structure clear, eg

class Triangle {
  void doStuff() {
    while (something) { 
      // do some stuff
    }
  }
}

Then highlight all your code and click the

icon just above the editor window - that puts tags before/after the code so its displayed properly (like my example above)[code]
icon just above the editor window - that puts tags before/after the code so its displayed properly (like my example above)

Thank you... I will do that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.