各位帮帮忙,我不是很懂重写这块,在此感激不尽
public class shap{
public double area;
public virtual double Area(double S)
{
this.area = S;
return S;
}
public double ShowArea()
{
Console.WriteLine("面积为{0}",area);
return area;
}
}
public class circle : shap
{
double radius;
public const double PI = 3.1416;
public circle(double S, double R)
: base(S)
{
// this.area=S;
this.radius = R;
}
public override double Area(double radius)
{
double area = PI * radius * radius;
return Console.ReadLine(area);
}
}
public class rectangle : shap
{
double length;
double width;
public rectangle(double S, double L, double W)
: base(S)
{
this.area=S;
this.length = L;
this.width = W;
}
public override double Area(double length,double width)
{
double area = length * width;
return Console.WriteLine(area) ;
}
}
class Program
{
static void Main(string[] args)
{
circle S1=new circle(4);
S1.Area();
rectangle S2= new rectangle (4.6);
S2.Area();
}
}
}