第六章,上机1
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第六章,上机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 }
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 }
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 }
以上是关于第六章,上机1的主要内容,如果未能解决你的问题,请参考以下文章