面向对象,继承,多态
using System;
namespace first1
{
public class Shape
{
protected string type;
protected double x, y;
public Shape()
{
x = 0;
y = 0;
type = "形状";
}
public Shape(double x, double y)
{
this.x = x;
this.y = y;
type = "形状";
}
public virtual double GetArea()
{
return x * y;
}
public string GetShapeType()
{
return type;
}
static void Main(string[] args)
{
Shape shape1, shape2;
shape1 = new Shape();
shape2 = new Shape(3, 7);
Console.WriteLine("园1的面积为:{0}", shape1.GetArea());
Console.WriteLine("园2的面积为:{0}", shape2.GetArea());
Console.ReadLine();
}
}
public c