zoukankan      html  css  js  c++  java
  • 第六章,上机练习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 }
  • 相关阅读:
    linux指令之系统信息查看
    linux指令之文件创建删除查看复制剪切
    c++函数参数类型-引用、指针、值 [转载]
    C++笔记 --- 头文件一览[转载]
    #include< >和#include""的区别
    DeleteFile()参数
    C++文件流读写详解
    Visual Studio中的Build和Rebuild区别
    STL 容器
    Android复习资料
  • 原文地址:https://www.cnblogs.com/yjjh/p/6691732.html
Copyright © 2011-2022 走看看