首页 新闻 会员 周边 捐助

java 抽象的问题,程序如下:请问我怎么输出什么都没有?

0
悬赏园豆:20 [已关闭问题] 关闭于 2013-04-27 18:35

import javax.swing.JOptionPane;

abstract class Area{
abstract double area();
}
class RoundArea extends Area{
double r;
RoundArea(){
r=0.0d;
}
RoundArea(double r){
this.r=r;
}
double area(){
JOptionPane.showMessageDialog(null,"输出圆面积"+(3.14*r*r));
return 3.14*r*r;
}
}
class RectArea extends Area{
double x;
double y;
RectArea(){
x=0.0d;
y=0.0d;
}
RectArea(double x,double y){
this.x=x;
this.y=y;
}
double area(){
JOptionPane.showMessageDialog(null,"输出矩形面积"+(x*y));
return x*y;
}
}
class ImpleArea extends RectArea{
void disa(){
String s1=JOptionPane.showInputDialog("输入半径");
double R=Double.parseDouble(s1);
new RoundArea(R);
}
void disb(){
String s2=JOptionPane.showInputDialog("输入长");
double C=Double.parseDouble(s2);
String s3=JOptionPane.showInputDialog("输入宽");
double K=Double.parseDouble(s3);
new RectArea(C,K);
}
}

class BB {
public static void main (String[] args) {
ImpleArea z=new ImpleArea();
z.disa();
z.disb();
}
}

懵懂新手的主页 懵懂新手 | 初学一级 | 园豆:183
提问于:2013-04-25 18:34
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册