码迷,mamicode.com
首页 > 其他好文 > 详细

第六章,上机1

时间:2017-04-11 10:02:06      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:rgs   open   gif   opened   sys   sha   main   ram   pen   

技术分享
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace Shang_1
 8 {
 9     public class Truck:Vehicle
10     {
11         public Truck(string type,string place):base(type,place){}
12         public void TruckRun()
13         {
14             Console.WriteLine("型号为{0}、产地为{1}的卡车在行驶!",this.Type,this.Place);
15         }
16     }
17 }
Truck类
技术分享
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace Shang_1
 8 {
 9     public class Vehicle
10     {
11         public string Type { get; set; }
12         public string Place { get; set; }
13         public Vehicle(string type, string place)
14         {
15             this.Type = type;
16             this.Place = place;
17         }
18         public void VehicleRun()
19         {
20             Console.WriteLine("汽车在行驶!");
21         }
22     }
23 }
Vehicle
技术分享
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace Shang_1
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             Truck truck = new Truck("奥迪A6","德国");
14             truck.VehicleRun();
15             truck.TruckRun();
16         }
17     }
18 }
Main

 

第六章,上机1

标签:rgs   open   gif   opened   sys   sha   main   ram   pen   

原文地址:http://www.cnblogs.com/lzx666/p/6691763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!