江湖救急。各位前辈帮帮忙啊
如何编写一个类Rect,两个变量height,weight,重载构造函数,计算面积,统计创建的对象的个数。最好帮忙写下代码啊。好人啊。高手啊。救救俺啊
------解决方案--------------------不懂lz的重载构造涵数....帮忙简单写一个吧.. 输入性正确之类就不判断了..还有计算些周长什么的都是数学问题...lz应该自己多试试编写代码..
public class Rect
{
private double _height;
private double _weight;
public static int count = 0;
public double height
{
get { return _height; }
set { _height = value; }
}
public double weight
{
get { return _weight; }
set { _weight = value; }
}
private Rect() { }
public Rect(double newHeight,double newWeight)
{
height = newHeight;
weight = newWeight;
count++;
}
public double Area()
{
return height * weight;
}
}