写了shape 跟Rectangle类。Circle的自己照葫芦画画吧,同学,貌似你问了不少你的作业问题啊。这样是不行的啊,其实你这些问题自己稍微看看书,容易做的,得为自己今后着想啊。
abstract class Shape
{
public abstract double GetArea();// 面积
public abstract double GetPerim();// 周长
}
public Class Rectangle :Sharp
{
private double length;
private double width;
public Rectangle (double len,double wid)
{
this.length = len;
this.width = wid;
}
public override double GetArea()
{
return this.length*this.width;
}
public override double GetPerim()
{
return 2*(this.length+this.width);
}
}