zoukankan      html  css  js  c++  java
  • 第六章,上机练习3

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 
     7 namespace SJ3_4
     8 {
     9     class Program
    10     {
    11         static void Main(string[] args)
    12         {
    13             List<Employee> empls = new List<Employee>();
    14             SE Joe=new SE("杰克",20,100);
    15             SE ai = new SE("艾边成", 25, 200);
    16             PM pm = new PM("艾斯", 30, 10);
    17             empls.Add(Joe);
    18             empls.Add(ai);
    19             empls.Add(pm);
    20             //foreach (Employee item in empls)
    21             //{
    22             //      Console.WriteLine(item.SayHi());
    23             //}
    24             for (int i = 0; i < empls.Count; i++)
    25             {
    26                 Console.WriteLine(empls[i].SayHi());
    27             }
    28         }
    29     }
    30 }
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 
     7 namespace SJ3_4
     8 {
     9     public class Employee
    10     {
    11         //姓名
    12         public string Name { get; set; }
    13         public int Age { get; set; }
    14         public virtual string SayHi() 
    15         {
    16             string message = string.Format("大家好");
    17             return message;
    18         }
    19         /// <summary>
    20         /// 构造函数
    21         /// </summary>
    22         public Employee(string name,int age) 
    23         {
    24             this.Name = name;
    25             this.Age = age;
    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 SJ3_4
     8 {
     9     /// <summary>
    10     /// 经理类
    11     /// </summary>
    12     public class PM:Employee
    13     {
    14         //管理经验
    15         public int YesarOfExperience { get; set; }
    16         //构造函数
    17         public PM(string name, int age, int yesarOfExperience): base(name, age)
    18         {
    19             this.YesarOfExperience = yesarOfExperience;
    20         }
    21         public override string SayHi() 
    22         {
    23             string message;
    24             message = string.Format("大家好,我是{0},今年{1},管理经验是{0}", this.Name, this.Age, this.YesarOfExperience);
    25             return message;
    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 SJ3_4
     8 {
     9     /// <summary>
    10     /// 程序员类
    11     /// </summary>
    12     public class SE:Employee
    13     {
    14         //人气
    15         public int Popularity { get; set; }
    16         public SE(string name, int age, int popularity) : base(name,age) 
    17         {
    18             this.Popularity = popularity;
    19         }
    20         /// <summary>
    21         /// SayHi
    22         /// </summary>
    23         /// <returns></returns>
    24         public override string SayHi() 
    25         {
    26             string message;
    27             message= string.Format("大家好,我是{0},今年{1},人气是{0}", this.Name, this.Age, this.Popularity);
    28             return message;
    29         }
    30     }
    31 }
  • 相关阅读:
    Bluetooth architecture (HCI/L2CAP)
    堆栈
    Inside the C++ Object Model 深度探索对象模型 57
    Android音乐播放器
    (一)开发板系统安装
    html5的canvas写一个简单的画板程序
    C++ 获取日历时间
    Incremental Differential vs. Incremental Cumulative Backups
    BCB安装控件出现Unresolved external '__fastcall Outline::TCustomOutline
    Windows 环境下配置 Oracle 11gR2 Data Guard 手记
  • 原文地址:https://www.cnblogs.com/yjjh/p/6691741.html
Copyright © 2011-2022 走看看