代码有n处红点,应该怎么根据内容进行修复呢?Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method addFactorial() is undefined for the type AppMain
at AppMain.main(AppMain.java:5)
下面是含错误的代码,求解决
class NoValueException extends RuntimeException
interface Shape //加上了Runtime
{
void getArea();
}
class Rec implements Shape
{
private int len , wid;
Rec(int len ,int wid)//throws NoValueException
{
if(len<=0 || wid<=0)
throw new NoValueException("出现非法值");
else
{
this.len = len;
this.wid = wid;
}
public void getArea{}
{
System.out.println(len*wid);
}
}
class Circle implements Shape
{
private int radius;
public static final double PI = 3.14;
Circle(int radius)
{
if (radius<=0)
throw new RuntimeException("非法")
this.radius = radius;
}
public void getArea()
{
System.out.println(radius*radius*PI);
}
}
class ExceptionTest1
{
public static void main(String[] args)
{
Rec r = new Rec(3,4);
r.getArea();
Circle c = new Circle(-8);
System.out.println(e.toString());
}
System.out.println("over");
cathc(*)
}
}
|