标题:小弟有问题请大哥帮忙
取消只看楼主
363057223
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-8-17
 问题点数:0 回复次数:0 
小弟有问题请大哥帮忙
下面是我刚写的程序请问错误是是: abstract class GeometricObject
{ protected String color;
protected double weight;
protected GeometricObject()
{ color ="white";
weight=1.0;
}
protected GeometricObject(String color,double weight)
{this.color=color;
this.weight=weight;
}
public String getColor()
{return color;
}
public void setColor(String color)
{this.color=color;
}
public double getWeight()
{return weight;
}
public void setWeight(double weight)
{this.weight=weight;
}
public abstract double findArea();
public abstract double findPerimeter();
}
class Triangle extends GemometricObject
{ private double side1,side2,side3;
Triangle(double side1,double side2,double side3)
{side1=3.0;
side2=4.0;
side3=5.0;
}
public double findArea()
{double s=(side1+side2+side3)/2;
double area=Math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
return area;
}
public double findPerimeter()
{double s=(side1+side2+side3)/2;
return s;
}
}
public class Example
{public static void main(String[] args)
{Triangle t=new Triangle();
double b=t.findArea();
System.out.println("the triangle''s s is:"+t.findPerimeter()+"now the triangle''s area is:"+t.findArea());
}
}
请各位大哥帮帮忙哈
搜索更多相关主题的帖子: abstract public double return white 
2005-08-17 17:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-25410-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.377395 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved