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
  • 相关阅读:
    安卓界面基本组件------计时器
    安卓界面组件----时间日期拾取器
    安卓界面组件----列表视图
    安卓组件------列表选择框
    Redis 开启远程访问
    收集的一个关于大批量插入数据的代码
    Server.MapPath和Request.PhysicalApplicationPath的异同
    C#中使用正则表达式验证电话号码、手机号、身份证号、数字和邮编
    cocos2d-x3.2在xcode6.1下的 环境搭建
    STL源码剖析(适配器)
  • 原文地址:https://www.cnblogs.com/qq2835200767/p/6691758.html
Copyright © 2011-2022 走看看