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
  • 相关阅读:
    iOS 6 Tutorials
    iPhone:文本设计的注意事项
    Beginning Storyboards in iOS 5 Part 2
    代友招聘一名网站开发人员
    利用反射自己写的一个ModelHelper类
    SQL中 对逻辑值取反赋值的语句
    记点uml的表现方式
    我的2008年
    Framework 4.0 新关键字dynamic 之我见(一)
    我的采集小程序配置篇
  • 原文地址:https://www.cnblogs.com/qq2835200767/p/6691758.html
Copyright © 2011-2022 走看看