第六章,上机1

 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

 

转载于:https://www.cnblogs.com/lzx666/p/6691763.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值