namespace 实验二
{
class Program
{
static void Main(string[] args)
{
Rectangle Juxing = new Rectangle();
Console.WriteLine("请输入长度:");
Juxing.chang = float.Parse(Console.ReadLine());
Console.WriteLine("请输入宽度:");
Juxing.kuan = float.Parse(Console.ReadLine());
Console.WriteLine("矩形面积:");
Juxing.show();
Circle yuan = new Circle();
Console.WriteLine("请输入半径:");
yuan.r = float.Parse(Console.ReadLine());
Console.WriteLine("圆面积:");
yuan.show();
Console.ReadLine();
}
}
public class Rectangle : Shape
{
public float chang;
public float kuan;
public float juxingArea()
{
return chang * kuan;
}
public override void show()
{
Console .WriteLine("{0}" , juxingArea());
}
}
public class Circle : Shape
{
public float r;
public double yuanArea()
{
return 3.14 * r * r;
}
public override void show()
{
Console.WriteLine("{0}", yuanArea());
}
}
}
namespace 实验二
{
public abstract class Shape
{
public abstract void show();
}
}这是完整代码
当我执行这个程序的时候 ,输入长宽和半径,不会输出面积,为什么呢