Redian新闻
>
一个关于继承的问题
avatar
一个关于继承的问题# Java - 爪哇娇娃
o*i
1
作业,里面有一个要求父类实例调用子类的方法..call a Cylinder method on a
Circle,不知道怎么搞,代码如下,谢谢大家..:
import java.text.*;
public class Circle {
DecimalFormat format=new DecimalFormat("#,###.00");
final double PI=3.1415926536;
double radius=0;
public Circle(){
radius=0;
}
public Circle(double r){
radius=r;
}
public void setRadius(double r){
radius=r;
}
public double getRadius(){
return radius;
}
public String toString(){
return "Radi
avatar
s*8
2
you can't.
the last stmt won't compile
More importantly, I don't see a reasonable is-a relationship between the two
. Maybe has-a relationship?
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。