欢迎来到天天文库
浏览记录
ID:38220949
大小:31.50 KB
页数:5页
时间:2019-05-25
《老师学生Word文档》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Form1usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespaceshiyan5_1{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidDoCollectHomework(IHo
2、meworkCollectorcollector){collector.CollectHomework();}privateIHomeworkCollectorCreateHomeworkCollector(stringtype){Teacherteac=newTeacher("李明","计算机学院");Studentstu=newStudent("张三","计算机软件专业");if(type=="teacher")returnteac;elsereturnstu;}privatevoidbutton1_Click(objectsender
3、,EventArgse){Teacherteac=newTeacher("李明","计算机学院");teac.CollectHomework();Studentstu=newStudent("张三","计算机软件专业");stu.CollectHomework();}privatevoidbutton2_Click(objectsender,EventArgse){Teachertea=newTeacher("李明","计算机学院");Studentstu=newStudent("张三","计算机软件专业");DoCollectHomewo
4、rk(tea);DoCollectHomework(stu);}privatevoidbutton3_Click(objectsender,EventArgse){IHomeworkCollectorcollector;collector=CreateHomeworkCollector("teacher");collector.CollectHomework();}}}StudentusingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Windows
5、.Forms;namespaceshiyan5_1{classStudent:Person,IHomeworkCollector{publicvoidCollectHomework(){MessageBox.Show("报告老师,作业收取完毕!");}privatestringmajor;publicstringMajor{get{returnmajor;}set{major=value;}}publicStudent(stringname,stringmajor):base(name){this.Major=major;}publicov
6、erridevoidintroduceMyself(){stringstr=string.Format("大家好,我是{0}的学生{1}",major,Name);MessageBox.Show(str);}}}PersonusingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceshiyan5_1{abstractclassPerson{privatestringname;publicstringName{get{returnname;}set{name=v
7、alue;}}publicPerson(stringname){this.Name=name;}publicabstractvoidintroduceMyself();}}TeacherusingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceshiyan5_1{abstractclassPerson{privatestringname;publicstringName{get{returnname;}set{name=value;}}publicPerso
8、n(stringname){this.Name=name;}publicabstractvoidintroduceMyself();}}
此文档下载收益归作者所有