模拟汽车行驶

来源:互联网 发布:淘宝追加评论怎么删除 编辑:程序博客网 时间:2024/04/28 15:45
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Day06_02{   public class Vehicle    {        public string Type{ get; set; }        public string Place{  get; set; }        public Vehicle() { }        public Vehicle(string type,string place)         {            this.Type= type;            this.Place =place;        }        public void VehicleRun()         {            Console.WriteLine("汽车在行驶!!");        }    }}

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Day06_02{   public class Truck:Vehicle    {            public Truck(string type,string place):base(type,place)       {}        public void TruckRun()       {           Console.WriteLine(string.Format("型号为{0},产地为{1}的卡车咋行驶!",this.Type,this.Place));       }    }}

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Day06_02 {    class Program    {        static void Main(string[] args)        {            Truck truck=new Truck("奥迪a6","德国");            truck.TruckRun();            truck.VehicleRun();            Console.ReadLine();        }    }}

0 0
原创粉丝点击