版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、一、 题目通用学生信息管理系统二、 基本功能要求1. 创建相应的成员变量保存学生基本信息;2. 创建相应属性和索引以实现对成员变量访问的封装;3. 创建相应的方法以实现对学生基本信息的管理;4. 创建相应的方法以实现对学生成绩的管理;5. 应用构造函数和析构函数;6. 派生小学生、中学生、大学生等子类;7. 运用继承、多态、重载、覆盖、接口、抽象类、代理、事件等。三、 题目分析1. 添加两个接口,定义成员便量如:学生姓名、性别等及科目信息;2. 添加抽象类student,实现接口及定义接口内的属性成员。构造函数student()用于学生信息的赋值。添加input()方法,实现对成员变量的输入;
2、添加show()方法和sumscore()方法对成员变量的数据输出及处理;添加一系列对于学生信息及成绩的管理的方法如changechinese方法(修改语文成绩)等。3. 定义派生类pupil,middleschoolstu,collegestu,并使用base关键字调用基类构造函数及添加额外的参数。在每个派生类中重写inpt(),show(),sumscore()方法便于调用;再额外添加一系列对于学生信息及成绩的管理的方法以实现在主函数中的管理功能。4. 在主函数中分别实现对大学生、中学生、小学生信息的一系列的管理功能:录入、浏览、查询、删除、修改。四、 功能设计基类student实现接口i
3、stuinformation和istuscore;派生类pupil继承基类student,中学生middleschoolstu类继承pupil类,大学生collegestu类继承middleschoolstu类;五、 源程序代码using system;using system.collections.generic;using system.linq;using system.text;using system.threading.tasks;namespace studentinformationmanagement interface istuinformation/第一个接口 stri
4、ng stuname get; set; /接口属性,获取学生姓名 string stusex get; set; /接口属性,获取学生性别 string stuage get; set; /接口属性,获取学生年龄 string stunatplace get; set; /接口属性,获取学生籍贯 interface istuscore/第二个接口 float chinesescore get; set; /接口属性,获取学生语文成绩 float mathscore get; set; /接口属性,获取学生数学成绩 /定义一个实现两个接口的抽象类student(基类),不能产生任何实例 pub
5、lic abstract class student : istuinformation,istuscore /定义私有成员 private string stuname; private string stusex; private string stuage; private string stunatplace; private float chinesescore; private float mathscore; /定义接口内的属性成员 public string stuname/用于访问私有变量stuname的属性 get return stuname; /get方法向外部返回属性
6、成员的值 set stuname = value; /set方法将外部写入的值用value关键字赋值给属性成员 public string stusex/用于访问私有变量stusex的属性 get return stusex; set stusex = value; public string stuage/用于访问私有变量stuage的属性 get return stuage; set stuage = value; public string stunatplace/用于访问私有变量stunatplace的属性 get return stunatplace; set stunatplace
7、 = value; public float chinesescore/用于访问私有变量chinesescore的属性 get return chinesescore; set chinesescore = value; public float mathscore/用于访问私有变量mathscore的属性 get return mathscore; set mathscore = value; /构造函数 public student(string stuname, string stusex, string stuage, string stunatplace, float chinese
8、score, float mathscore) this.stuname = stuname;/用this关键字调用当前类的成员,赋值 this.stusex = stusex; this.stuage = stuage; this.stunatplace = stunatplace; this.chinesescore = chinesescore; this.mathscore = mathscore; /析构函数 student() /定义一个表示输入数据成员的虚方法 public virtual void input() console.writeline(请输入要录入的学生的基本信息
9、和成绩:); console.write(姓名:); stuname = console.readline(); console.write(性别:); stusex = console.readline(); console.write(年龄:); stuage = console.readline(); console.write(籍贯:); stunatplace = console.readline(); console.write(语文:); chinesescore = float.parse(console.readline(); console.write(数学:); math
10、score = float.parse(console.readline(); /定义抽象方法,具体内容在派生类中实现 public abstract void show();/输出学生信息的方法 public abstract void sumscore();/输出学生成绩总分及平均分的方法 /定义方法来对学生信息及成绩的处理 public void changestuage(string age)/修改学生年龄 stuage = age; console.writeline(修改成功!); public void changestunatplace(string nation)/修改学生籍
11、贯 stunatplace = nation; console.writeline(修改成功!); public void changechinese(float chinese)/修改学生语文成绩 chinesescore = chinese; console.writeline(修改成功!); /继承抽象类student,形成pupil子类 class pupil : student protected float englishscore; /构造函数,继承 public pupil(string stuname, string stusex, string stuage, string
12、 stunatplace, float chinesescore, float mathscore, float englishscore) : base(stuname, stusex, stuage, stunatplace, chinesescore, mathscore)/通过base关键字调用基类构造函数 /析构函数 pupil() /重写基类的虚方法,增加成员 public override void input() base.input();/用base关键字访问基类的input()方法 console.write(英语:); englishscore = float.parse
13、(console.readline(); public override void show()/重写基类中的定义抽象的方法 console.writeline(学生基本信息:); console.writeline(姓名:0,性别:1,年龄:2,籍贯:3, stuname, stusex, stuage, stunatplace); console.writeline(学生成绩信息:); console.writeline(语文:0,数学:1,英语:2, chinesescore, mathscore, englishscore); public override void sumscore
14、()/重写基类中的定义抽象的方法 float sum = chinesescore + mathscore + englishscore; float average = sum / 3; console.writeline(总成绩:0,平均分:1, sum, average); /定义带引用型和输出型参数的方法成员,包含的是数据的存储地址 public void searchstuname(ref string name,out int w)/查找学生姓名 if (name = stuname) w = 1; else w = 0; public void changeenglish(flo
15、at english)/修改学生英语成绩 englishscore = english; console.writeline(修改成功!); /定义中学生类,继承小学生类 class middleschoolstu : pupil protected string contactway; protected float physicsscore; protected float chemistryscore; /构造函数 public middleschoolstu(string stuname, string stusex, string stuage, string stunatplace
16、, string contactway, float chinesescore, float mathscore, float englishscore, float physicsscore, float chemistryscore) : base(stuname, stusex, stuage, stunatplace, chinesescore, mathscore, englishscore) this.contactway = contactway;/this调用当前类的成员 this.physicsscore = physicsscore; this.chemistryscore
17、 = chemistryscore; /析构函数 middleschoolstu() /重载基类的方法,增加三个输入数据成员 public override void input() base.input();/用base关键字访问基类的input()方法 console.write(联系方式:); contactway = console.readline(); console.write(物理:); physicsscore = float.parse(console.readline(); console.write(化学:); chemistryscore = float.parse(
18、console.readline(); public override void show()/重载基类的方法 console.writeline(学生基本信息:); console.writeline(姓名:0,性别:1,年龄:2,籍贯:3,联系方式:4, stuname, stusex, stuage, stunatplace, contactway); console.writeline(学生成绩信息:); console.writeline(语文:0,数学:1,英语:2,物理:3,化学:4, chinesescore, mathscore, englishscore, physicss
19、core, chemistryscore); public override void sumscore()/重载基类的方法 float sum = chinesescore + mathscore + englishscore + chemistryscore + physicsscore; float average = sum / 5; console.writeline(总成绩:0,平均分:1, sum, average); public void changestucontactway(string conway)/修改学生联系方式 contactway = conway; cons
20、ole.writeline(修改成功!); public void changephysics(float physics)/修改学生物理成绩 physicsscore = physics; console.writeline(修改成功!); /定义大学生类,继承中学生类 class collegestu : middleschoolstu static string stuid;/定义一个私有的静态变量成员 protected float computerscore; /构造函数 public collegestu(string stuname, string stuid, string s
21、tusex, string stuage, string stunatplace, string contactway, float chinesescore, float mathscore, float englishscore, float physicsscore, float chemistryscore, float computerscore) : base(stuname, stusex, stuage, stunatplace, contactway, chinesescore, mathscore, englishscore, physicsscore, chemistry
22、score) stuid = stuid; /stuid是静态属性,不能用this关键字 puterscore = computerscore; /析构函数 collegestu() /重写基类的方法,增加两个输入数据成员 public override void input() base.input();/用base关键字访问基类的input()方法 console.write(学号:); stuid = console.readline(); console.write(计算机:); computerscore = float.parse(console.readline(
23、); new public void show()/new关键字覆盖基类成员 console.writeline(学生基本信息:); console.writeline(姓名:0,学号:1,性别:2,年龄:3,籍贯:4,联系方式:5, stuname, stuid, stusex, stuage, stunatplace, contactway); console.writeline(学生成绩信息:); console.writeline(语文:0,数学:1,英语:2,物理:3,化学:4,计算机:5, chinesescore, mathscore, englishscore, physics
24、score ,chemistryscore, computerscore); new public void sumscore()/new关键字覆盖基类成员 float sum = chinesescore + mathscore + englishscore + chemistryscore + physicsscore + computerscore; float average = sum / 6; console.writeline(总成绩:0,平均分:1, sum, average); public static string getstuid()/定义一个静态方法,获得学号 ret
25、urn(stuid);/静态方法访问静态变量 /定义带引用型和输出型参数的方法成员,包含的是数据的存储地址 public void searchstuid(ref string id, out int w)/查找学生学号 if (id = getstuid()/访问静态方法 w = 1; else w = 0; public void changecomputer(float computer)/修改学生计算机成绩 computerscore = computer; console.writeline(修改成功!); class program public static void funct
26、ion()/定义一个静态方法,在主函数中调用 console.writeline(* 1.学生信息浏览;*); console.writeline(* 2.学生信息查找;*); console.writeline(* 3.学生信息删除;*); console.writeline(* 4.学生信息修改;*); console.writeline(* 0.退出;*); static void main(string args) console.writeline(*欢迎使用学生通用信息管理系统*); console.writeline(); console.write(请选择要管理的学生类型(1.
27、大学生,2.中学生,3.小学生):); int c = int.parse(console.readline(); switch (c) case 1: collegestu g = new collegestu100;/定义对象数组 int length = 0; for (int i = 0; i = length; i+) gi = new collegestu(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);/实例化对象 gi.input(); console.write(是0否继续录入信息(输入“y”或者“n”):); string m = console.r
28、eadline(); if (m = n) break; length+; console.writeline(您一共录入0个学生信息。, length + 1); console.writeline(); console.writeline(以下是系统基本操作:); program.function(); console.writeline(); console.write(请选择您要执行的操作:); int a = int.parse(console.readline();/将字符串类型转换为整型 console.writeline(); if (a = 1) /使用foreach循环访问
29、数组的每一个元素,g是类的对象,g是对象数组 foreach (collegestu g in g) g.show(); g.sumscore(); else if (a = 2) string yn; do console.writeline(* 1.按学生姓名查找;*); console.writeline(* 2.按学生学号查找;*); console.writeline(* 0.退出;*); console.write(请选择您要执行的操作:); int b = int.parse(console.readline(); if (b = 1) console.write(请输入要查找学
30、生的姓名:); string name = console.readline(); int w, j = 0; for (int i = 0; i = length; i+) gi.searchstuname(ref name, out w); if (w = 1) gi.show(); gi.sumscore(); j+; console.writeline(找到的结果为0个。, j); else if (b = 2) console.write(请输入要查找学生的学号:); string id = console.readline(); int w, j = 0; for (int i =
31、 0; i = length; i+) gi.searchstuid(ref id, out w); if (w = 1) gi.show(); gi.sumscore(); j+; console.writeline(找到的结果为0个。, j); else break; console.write(是否继续查找(选择“y”或者“n”):); yn = console.readline(); while (yn = y); else if (a = 3) console.writeline(请输入要删除的学生姓名:); string name = console.readline(); for (int i = 0; i = length; i+) if (name = gi.stuname) gi =
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年烧烤店夏季营销活动策划
- 2026年露营经济产业链深度解析与营地运营模式报告
- 2026年证券投资分析综合实训教程
- 2026年基于虚拟仿真技术的临床教学案例开发
- 2026浙江杭州市学军小学教育集团紫金港小学诚聘教师(非事业)1人考试备考试题及答案解析
- 2026年中医皮肤科湿疹诊疗流程模拟测试卷及答案
- 2026年加油站防雷应急演练方案
- 2026年煤化工技术(煤制甲醇工艺)专项测试题及答案
- 2026年人工智能在文物保护与修复中的应用:国际实践与未来
- 2026年特殊教育AI辅助沟通教学案例
- 高考反复修辞示例与训练
- 青马结业个人总结汇报
- 婚礼上女方家长的精彩讲话稿7篇
- ecotect教程教学课件
- 综合实践活动(4年级下册)第4课时 换季衣物巧收纳-课件
- 抗挫折能力课件(修改)
- 2023年江苏省高中生物学竞赛初赛试题
- 不锈钢护栏施工方案方案
- 陕西境某段高速公路建设工程地质灾害危险性评估报告报告
- 母亲的白发阅读及答案
- GB/T 8237-2005纤维增强塑料用液体不饱和聚酯树脂
评论
0/150
提交评论