c#编程求圆的面积和长方体的体积,要求用接口实现

来源:百度知道 编辑:UC知道 时间:2024/05/22 19:51:13

const double P=3.1415926;
public interface s
{
double getarea(double lenth,double width, double height);
double getcirle(double r);
}

public class ss : s
{
public double getarea(double length,double width, double height)
{
return length*width * height;
}

public double getcirle(double r, double c)
{
return P*r*r;
}
}

interface area
{
double getarea(double width, double height);
double getcirle(double r, double c);
}

public class app : area
{
public double getarea(double width, double height)
{
return width * height;
}

public double getcirle(double r, double c)
{
return r * c;
}
}