zoukankan      html  css  js  c++  java
  • (深入.Net平台和C#编程)第六章上机练习1.李向阳.20170411

     1 =============Truck类==========
     2 using System;
     3 using System.Collections.Generic;
     4 using System.Linq;
     5 using System.Text;
     6 using System.Threading.Tasks;
     7 
     8 namespace SJ1.entity
     9 {
    10     /// <summary>
    11     /// 卡车类
    12     /// </summary>
    13     public class Truck : Vehicle
    14     {
    15        public Truck(string xinghao, string chandi):base(xinghao,chandi)
    16        {}
    17        /// <summary>
    18        /// TruckRun()
    19        /// </summary>
    20        public void TruckRun()
    21        {
    22            Console.WriteLine(string.Format("型号是:{0},产地是{1}的卡车在行驶!",Xinghao,Chandi));
    23        }
    24     }
    25 
    26 }
    View Code
     1 =============Vehicle类==============
     2 using System;
     3 using System.Collections.Generic;
     4 using System.Linq;
     5 using System.Text;
     6 using System.Threading.Tasks;
     7 
     8 namespace SJ1.entity
     9 {
    10     /// <summary>
    11     /// 汽车类
    12     /// </summary>
    13     public class Vehicle
    14     {
    15         public string Xinghao { get; set; } //型号
    16         public string Chandi { get; set; }  //产地
    17         /// <summary>
    18         /// 构造函数
    19         /// </summary>
    20         /// <param name="xinghao"></param>
    21         /// <param name="chandi"></param>
    22         public Vehicle(string xinghao, string chandi)
    23         {
    24             this.Xinghao = xinghao;
    25             this.Chandi = chandi;
    26         }
    27         /// <summary>
    28         /// VehiclRun()方法
    29         /// </summary>
    30         public void VehicleRun()
    31         {
    32             Console.WriteLine("汽车在行驶");
    33         }
    34     }
    35 }
    View Code
     1 =============测试类==============
     2 using SJ1.entity;
     3 using System;
     4 using System.Collections.Generic;
     5 using System.Linq;
     6 using System.Text;
     7 using System.Threading.Tasks;
     8 
     9 namespace SJ1
    10 {
    11     class Program
    12     {
    13         static void Main(string[] args)
    14         {
    15             Truck truck = new Truck("奥迪A6","德国");
    16             truck.TruckRun();
    17             truck.VehicleRun();
    18             Console.Read();
    19 
    20         }
    21     }
    22 }
    View Code
  • 相关阅读:
    eureka注册中心搭建
    MySQL基本查询语句
    通过IP地址和子网掩码与运算计算相关地址
    Linux bash 快捷键列表【转】
    Linux 系统简介【转】
    Linux Vim -d 比较两个文件
    无连接和面向连接协议的区别【转】
    ARP报文详解
    Linux 指定网卡 ping
    Linux Windows Java 快速生成指定大小的空文件
  • 原文地址:https://www.cnblogs.com/qq2835200767/p/6691758.html
Copyright © 2011-2022 走看看