复习接口

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 复习接口
{
    class Program
    {
        static void Main(string[] args)
        {
            //父类引用指向子类对象。
            Flyable f = new UFO();
            f.Fly();
            Console.ReadKey();
        }
    }
    interface Flyable
    {
        void Fly();

    }

    class Bird : Flyable
    {

        public void Fly()
        {
            Console.WriteLine("小鸟飞呀飞");
        }
    }
    class Plane : Flyable
    {
        public void Fly()
        {
            Console.WriteLine("灰机飞!");
        }
    }

    class UFO : Flyable
    {
        public void Fly()
        {
            Console.WriteLine("看,飞碟!");
        }
    }
}

  

posted @ 2013-08-25 18:16  小新+  阅读(129)  评论(0)    收藏  举报