如何用java编写类 Circle(圆) 和类 Rectangle(矩形) ,

问题描述:

如何用java编写类 Circle(圆) 和类 Rectangle(矩形) ,
1个回答 分类:综合 2014-10-03

问题解答:

我来补答
public class Rectangle
{
private double width;
private double length;
public double getWidth()
{
return width;
}
public void setWidth(double width)
{
this.width = width;
}
public double getLength()
{
return length;
}
public void setLength(double length)
{
this.length = length;
}

public double mianji()
{
return width*length;
}
public double zhouchang()
{
return (width+length)*2;
}
}
public class Circle
{
private double r;
public double getR()
{
return r;
}
public void setR(double r)
{
this.r = r;
}
public double zhouchang()
{
return 2*Math.PI*r;
}
public double mianji()
{
return Math.PI*r*r;
}
}
 
 
展开全文阅读
剩余:2000
上一页:解不等式
也许感兴趣的知识