孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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

namespace ConsoleApplication2
{
    class Program
    {
        abstract public class MotorVehicle
        {
            public string make;
            public string model;

            public MotorVehicle(string make, string model)
            {
                this.make = make;
                this.model = model;
            }
            abstract public void Accelerate();
        }

        public class Car : MotorVehicle
        {
            public Car(string make, string model)
                : base(make, model)
            {
                //do nothing
            }

            public override void Accelerate()
            {
                Console.WriteLine("In Car Accelerate() method");
                Console.WriteLine(model + " accelerating");
            }
        }

        static void Main(string[] args)
        {
            Console.WriteLine("Creating a Car object");
            Car myCar = new Car("Toyata","MR2");

            Console.WriteLine("Calling myCar.Accelerate()");
            myCar.Accelerate();
            string i = System.Console.ReadLine();
        }
    }
}

posted on 2011-05-03 19:45  孤独的猫  阅读(136)  评论(0编辑  收藏  举报