using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//类的多态例子
namespace PolymoDemo
{
internal class Program
{
private Program[] qtest = new Program[6];
private int nextIndex = 0;
public void draw(Program q)
{
if(nextIndex < qtest.Length)
{
qtest[nextIndex] = q;
Console.WriteLine(nextIndex);
nextIndex++;
}
}
static void Main(string[] args)
{
Program q = new Program();
q.draw(new Square());
q.draw(new Parallelogramgle());
Console.WriteLine();
}
}
class Square:Program
{
public Square()
{
Console.WriteLine("正方形");
}
}
class Parallelogramgle:Program
{
public Parallelogramgle()
{
Console.WriteLine("平行四边形");
}
}
}