我已经处理这个问题一个星期了,虽然我找到了一些答案,但似乎没有一个能解决我程序的问题。
我不断收到此消息:
Note: Triangle.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
这是代码:
import java.util.*;
public class Triangle
{
public double a;
public double b;
private double c;
private ArrayList btsarr;
private static int numMade = 0;
public Triangle()
{
this.a = 3;
this.b = 4;
this.c = 5;
this.btsarr = new ArrayList();
this.btsarr.add(this.c + ""); //adding it as a String object
Triangle.numMade++;
}
public Triangle(double x1, double x2, double x3)
{
this.a = x1; //specs say no data validation necessary on parameters
this.b = x2;
this.c = x3;
this.btsarr = new ArrayList();
this.btsarr.add(this.c + "");
Triangle.numMade++;
}
public void setC(double x)
{
if (x <= 0)
{
System.out.println("Illegal, can't set c to 0 or negative");
}
else
{
this.c = x;
this.btsarr.add(this.c + "");
}
}
public double getC()
{
return this.c;
}
public void showAllCs()
{
System.out.println(this.btsarr);
}
public boolean isRightTriangle()
{
if (this.a*this.a + this.b*this.b == this.c*this.c)
return true;
else
return false;
}
public static int getNumMade()
{
return Triangle.numMade;
}
}
感谢您提供任何帮助,谢谢!