博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第六章,上机3
阅读量:5265 次
发布时间:2019-06-14

本文共 4635 字,大约阅读时间需要 15 分钟。

1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6  7 namespace WindowsFormsApplication1 8 { 9     public class Employee10     {11         public int Age { get; set; }12         public Gender Gender { get; set; }13         public string ID { get; set; }14         public string Name { get; set; }15         protected List
WorkList { get; set; }16 public Employee(string id, int age, string name, Gender gender, List
list)17 {18 this.ID = id;19 this.Age = age;20 this.Name = name;21 this.Gender = gender;22 this.WorkList = list;23 }24 public virtual string DoWork()25 {26 return "";27 }28 }29 }
父类
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6  7 namespace WindowsFormsApplication1 8 { 9     public enum Gender10     {11         男,12         女13     }14 }
枚举类
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6  7 namespace WindowsFormsApplication1 8 { 9     public class Job10     {11         public string Name { get; set; }12         public string Description { get; set; }13 14         public Job(string name, string description)15         {16             this.Name = name;17             this.Description = description;18         }19     }20 }
Job
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6  7 namespace WindowsFormsApplication1 8 { 9     public class PM:Employee10     {11         public int YearOfExperience { get; set; }12         public override string DoWork()13         {14             string message = this.Name + "管理员完成工作内容!";15             return message;16         }17         public PM(string id, int age, string name, Gender gender, List
list, int yearOfExperience)18 : base(id, age, name, gender, list)19 {20 this.YearOfExperience = yearOfExperience;21 }22 }23 }
PM类
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6  7 namespace WindowsFormsApplication1 8 { 9     public class SE:Employee10     {11         public int _popularity;12         public int Popularity { get; set; }13         public override string DoWork()14         {15             StringBuilder sb = new StringBuilder();16             sb.Append(this.Name + ":\n");17             for (int i = 0; i < this.WorkList.Count; i++)18             {19                 sb.Append((i + 1) + "、" + WorkList[i].Name + ":" + WorkList[i].Description + "\n");20             }21             return sb.ToString();22         }23         public SE(string id, int age, string name, Gender gender, List
list, int popularity)24 : base(id, age, name, gender, list)25 {26 this.Popularity = popularity;27 }28 }29 }
SE类
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms;10 11 namespace WindowsFormsApplication112 {13     public partial class FrmMain : Form14     {15         public FrmMain()16         {17             InitializeComponent();18             Init();19         }20         //员工集合21         List
empls = new List
();22 //员工信息初始化23 public void Init()24 {25 //实例化SE对象26 List
list1 = new List
();27 list1.Add(new Job("编码", "购物车模块"));28 list1.Add(new Job("测试", "给购物车模块做单元测试"));29 SE yu = new SE("112", 17, "俞++", Gender.男, list1, 100);30 31 List
list2 = new List
();32 list2.Add(new Job("设计", "数据库建模"));33 list2.Add(new Job("编写文档", "详细设计说明书"));34 SE joe = new SE("111", 25, "Joe", Gender.男, list2, 200);35 36 //实例化PM对象37 PM pm = new PM("809", 50, "盖茨", Gender.男, null, 30);38 empls.Add(yu);39 empls.Add(joe);40 empls.Add(pm);41 }42 43 private void btnRender_Click(object sender, EventArgs e)44 {45 foreach (Employee emp in empls)46 {47 MessageBox.Show(emp.DoWork(), "汇报");48 }49 }50 51 }52 }
Main

 

 

转载于:https://www.cnblogs.com/lzx666/p/6691767.html

你可能感兴趣的文章
CF219D Choosing Capital for Treeland
查看>>
杂七杂八的小笔记本
查看>>
51Nod1353 树
查看>>
CF1215E Marbles
查看>>
fish redux 个人理解
查看>>
BZOJ2339 HNOI2011卡农(动态规划+组合数学)
查看>>
octave基本操作
查看>>
axure学习点
查看>>
WPF文本框只允许输入数字[转]
查看>>
dom4j 通用解析器,解析成List<Map<String,Object>>
查看>>
第一个项目--用bootstrap实现美工设计的首页
查看>>
使用XML传递数据
查看>>
TYVJ.1864.[Poetize I]守卫者的挑战(概率DP)
查看>>
基于CMMI的敏捷开发过程文档裁剪
查看>>
0925 韩顺平java视频
查看>>
软件需求规格说明书
查看>>
53. Maximum Subarray
查看>>
iOS-程序启动原理和UIApplication
查看>>
SpringMVC入门(二)—— 参数的传递、Controller方法返回值、json数据交互、异常处理、图片上传、拦截器...
查看>>
git的安装
查看>>