• 第六章,上机练习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 No._6 8 { 9 class Program 10 { 11 /// <summary> 12 /// 测试类Main()方法 13 /// </summary> 14 static void Main(string[] args) 15 { 16 Truck truck = new Truck("奥迪A6", "德国"); 17 18 truck.TruckRun(); 19 } 20 } 21 }
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 
     7 namespace No._6
     8 {
     9     public class Truck:Vehicle
    10     {
    11         /// <summary>
    12         /// 结构函数
    13         /// </summary>
    14         /// <param name="Type"></param>
    15         /// <param name="Place"></param>
    16         public Truck(string Type, string Place):base(Type,Place)
    17         {
    18 
    19         }
    20         /// <summary>
    21         /// 输出方法
    22         /// </summary>
    23         public void TruckRun() 
    24         {
    25             Console.WriteLine("型号为"+this.Type+",产地为"+this.Place+"的卡车在行驶!");
    26         }
    27     }
    28 }
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 
     7 namespace No._6
     8 {
     9     /// <summary>
    10     /// 汽车类
    11     /// </summary>
    12     public class Vehicle
    13     {
    14         //型号
    15         public string  Type { get; set; }
    16         //产地
    17         public string Place { get; set; }
    18         //构造函数
    19         public Vehicle(string type,string place) 
    20         {
    21             this.Type = type;
    22             this.Place = place;
    23         }
    24     }
    25 }
  • 相关阅读:
    SCAU 12新生赛 H 拥挤的华农校巴
    C#实现让CPU占用率曲线听你的指挥 可指定运行核心
    追MM与设计模式的有趣见解
    FTP操作类
    怎么知道页面被放大缩小了
    SerialPort同步和异步数据读取
    Java Web 应用程序转换为 ASP.NET
    ASP.NET中进行消息处理(MSMQ)
    解压缩文件类
    怎样成为优秀的软件模型设计者?
  • 原文地址:https://www.cnblogs.com/yjjh/p/6691732.html
Copyright © 2020-2023  润新知