首页 > 代码库 > (深入.Net平台和C#编程)第六章上机练习1.李向阳.20170411

(深入.Net平台和C#编程)第六章上机练习1.李向阳.20170411

技术分享
 1 =============Truck类========== 2 using System; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7  8 namespace SJ1.entity 9 {10     /// <summary>11     /// 卡车类12     /// </summary>13     public class Truck : Vehicle14     {15        public Truck(string xinghao, string chandi):base(xinghao,chandi)16        {}17        /// <summary>18        /// TruckRun()19        /// </summary>20        public void TruckRun()21        {22            Console.WriteLine(string.Format("型号是:{0},产地是{1}的卡车在行驶!",Xinghao,Chandi));23        }24     }25 26 }
View Code
技术分享
 1 =============Vehicle类============== 2 using System; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7  8 namespace SJ1.entity 9 {10     /// <summary>11     /// 汽车类12     /// </summary>13     public class Vehicle14     {15         public string Xinghao { get; set; } //型号16         public string Chandi { get; set; }  //产地17         /// <summary>18         /// 构造函数19         /// </summary>20         /// <param name="xinghao"></param>21         /// <param name="chandi"></param>22         public Vehicle(string xinghao, string chandi)23         {24             this.Xinghao = xinghao;25             this.Chandi = chandi;26         }27         /// <summary>28         /// VehiclRun()方法29         /// </summary>30         public void VehicleRun()31         {32             Console.WriteLine("汽车在行驶");33         }34     }35 }
View Code
技术分享
 1 =============测试类============== 2 using SJ1.entity; 3 using System; 4 using System.Collections.Generic; 5 using System.Linq; 6 using System.Text; 7 using System.Threading.Tasks; 8  9 namespace SJ110 {11     class Program12     {13         static void Main(string[] args)14         {15             Truck truck = new Truck("奥迪A6","德国");16             truck.TruckRun();17             truck.VehicleRun();18             Console.Read();19 20         }21     }22 }
View Code

 

(深入.Net平台和C#编程)第六章上机练习1.李向阳.20170411