黑马程序员技术交流社区
标题:
我在打10天-04-面向对象(异常-练习)
[打印本页]
作者:
hjz564
时间:
2013-6-6 22:39
标题:
我在打10天-04-面向对象(异常-练习)
代码有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(*)
}
}
作者:
李奔
时间:
2013-6-6 23:32
我看了半天,没看出什么东西。
又在VS中运行了一下,才发现这是JAVA程序。
同学这里是.NET区,你问错地方了,请移步到JAVA区!
我花了十几分钟来看程序,能给加点技术分吗?
谢谢!
作者:
一直在努力
时间:
2013-6-7 22:33
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(*)
}
}
cathc(*)这个是什么意思..求解?
作者:
彭家贰小姐
时间:
2013-6-7 22:41
看到你两次了 {:soso_e144:} 你还是没回java
作者:
关关雎鸠
时间:
2013-6-8 22:27
晕,跑.net板块问。。
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2