通用学生信息管理系统c#程序报告材料_第1页
通用学生信息管理系统c#程序报告材料_第2页
通用学生信息管理系统c#程序报告材料_第3页
已阅读5页,还剩35页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、题目通用学生信息管理系统基本功能要求1. 创建相应的成员变量保存学生基本信息;2. 创建相应属性和索引以实现对成员变量访问的封装;3. 创建相应的方法以实现对学生基本信息的管理;4. 创建相应的方法以实现对学生成绩的管理;5. 应用构造函数和析构函数;6. 派生小学生、中学生、大学生等子类;7. 运用继承、多态、重载、覆盖、接口、抽象类、代理、事件等。三、题目分析1. 添加两个接口,定义成员便量如:学生、性别等及科目信息;2. 添加抽象类student,实现接口及定义接口的属性成员。构造函数student()用于学生信息的赋值。添加in put ()方法,实现对成员变量的输 入;添加show(

2、)方法和sumScore ()方法对成员变量的数据输出及 处理;添加一系列对于学生信息及成绩的管理的方法如 changeChinese 方法(修改语文成绩)等。3. 定义派生类 pupil,middleSchoolStu, collegeStu,并使用 base 关键字 调用基类构造函数及添加额外的参数。在每个派生类中重写 inpt(), show(),sumScore ()方法便于调用;再额外添加一系列对于学生信 息及成绩的管理的方法以实现在主函数中的管理功能。4. 在主函数中分别实现对大学生、中学生、小学生信息的一系列的管理 功能:录入、浏览、查询、删除、修改。四、功能设计基类 Stude

3、nt实现接口 Istulnformation 和 IstuScore;派生类pupil继承基类Student,中学生middleSchoolStu类继承pupil类,大学生 collegeStu 类继承 middleSchoolStu 类;Isculnformitior:'1-SciiXinw-£TrtS<K.一尔四:盘FA£lnA<-e:*iaKtJX屯:詬乂幕订:L嘗T五、源程序代码using System;using System.Linq;using System.Text;namespace studentInformationManageme

4、ntin terface Istul nformatio n 第一个接口string StuName get; set; /接口属性,获取学生string StuSex get; set; /接口属性,获取学生性别string StuAge get; set; /接口属性,获取学生年龄string StuNatPlace get; set; /接口属性,获取学生籍贯in terface IstuScore/第二个接口float ChineseScore get; set; /接口属性,获取学生语文成绩float MathScore get; set; /接口属性,获取学生数学成绩定义一个实现两

5、个接口的抽象类student (基类),不能产生任何实例public 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 st

6、uName; /get 方法向外部返回属性成员的 值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 stuNatPl

7、ace; set stuNatPlace = 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 stuNatP

8、lace, float chineseScore, 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()Con sole.Wr

9、iteLi ne("请输入要录入的学生的基本信息和Console.Write(":");StuName = Console.ReadLine();Console.Write("性别:");StuSex = Console.ReadLine();Console.Write("年龄:");StuAge = Console.ReadLine();Console.Write(”籍贯:");StuNatPlace = Console.ReadLine();Console.Write("语文:");Chin

10、eseScore = float.Parse(Console.ReadLine();Console.Write("数学:");MathScore = float.Parse(Console.ReadLine();/定义抽象方法,具体容在派生类中实现public abstract void show();/输出学生信息的方法public abstract void sumScore();/输出学生成绩总分及平均分/定义方法来对学生信息及成绩的处理public void cha ngeStuAge(stri ng age)/修改学生年龄stuAge = age;Co nsole

11、.WriteLi ne(” 修改成功!");public void cha ngeStuNatPlace(stri ng natio n)/修改学生籍贯stuNatPlace = nation;Co nsole.WriteLi ne(” 修改成功!");public void cha ngeCh in ese(float chin ese)/修 改学生语文成绩chineseScore = chinese;Co nsole.WriteLi ne(” 修改成功!");继承抽象类student,形成pupil子类class pupil : Studentprotecte

12、d float englishScore;/构造函数,继承public pupil(string stuName, string stuSex, string stuAge, string stuNatPlace, float chineseScore, float mathScore, float englishScore): base(stuName, stuSex, stuAge, stuNatPlace,chineseScore, mathScore)通过base关键字调用基类构造函数 /析构函数 pupil() /重写基类的虚方法,增加成员 public override void

13、input()base.i nput();/用base关键字访问基类的in put ()方法Console.Write(”英语:");englishScore = float.Parse(Console.ReadLine();public override void show()/重写基类中的定义抽象的方法Con sole.WriteLi ne(” 学生基本信息:");Console.WriteLine(": 0, 性别: 1, 年龄: 2, 籍贯: 3", StuName, StuSex, StuAge, StuNatPlace);Con sole.W

14、riteLi ne(” 学生成绩信息:");Console.WriteLine(”语文:0,数学:1,英语:2", ChineseScore, MathScore, englishScore);public override void sumScore()重写基类中的定义抽象的方float sum = ChineseScore + MathScore + englishScore; float average = sum / 3;Console.WriteLine(”总成绩:0,平均分: ",sum, average);/定义带引用型和输出型参数的方法成员,包含的

15、是数据的 存储地址public void searchStuName(ref stri ng Name,out int w) 查找学 生if (Name = StuName)w = 1;elsew = 0;public void cha ngeE nglish(float en glish)/修 改学生英语成绩englishScore = english;Co nsole.WriteLi ne(” 修改成功!");/定义中学生类,继承小学生类 class middleSchoolStu : pupilprotected string contactWay;protected floa

16、t physicsScore; protected float chemistryScore;/构造函数public middleSchoolStu(string stuName, string stuSex, string stuAge, string stuNatPlace, string contactWay, float chineseScore, float mathScore, float englishScore, float physicsScore, float chemistryScore): base(stuName, stuSex, stuAge, stuNatPlac

17、e, chineseScore, mathScore, englishScore)this.con tactWay = con tactWay;/this调用当前类的成员this.physicsScore = physicsScore;this.chemistryScore = chemistryScore;/析构函数 middleSchoolStu() /重载基类的方法,增加三个输入数据成员 public override void input()base.i nput();/用base关键字访问基类的in put ()方法Con sole.Write(” 联系方式:"); con

18、tactWay = Console.ReadLine();Console.Write("物理:"); physicsScore = float.Parse(Console.ReadLine();Console.Write("化学:");chemistryScore = float.Parse(Console.ReadLine();public override void show() 重载基类的方法Con sole.WriteLi ne(” 学生基本信息:");Console.WriteLine(": 0, 性别: 1, 年龄: 2,

19、 籍贯: 3, 联系方式: 4", StuName, StuSex, StuAge, StuNatPlace, contactWay);Con sole.WriteLi ne(” 学生成绩信息:");Console.WriteLine(”语文:0,数学:1,英语:2,物 理: 3, 化学: 4", ChineseScore, MathScore, englishScore, physicsScore, chemistryScore);public override void sumScore()/重载基类的方法float sum = ChineseScore +

20、MathScore + englishScore + chemistryScore + physicsScore;float average = sum / 5;Console.WriteLine(”总成绩:0,平均分:1", sum, average);public void changeStuContactWay(stringconWay)/修改学生 联系方式contactWay = conWay;Co nsole.WriteLi ne(” 修改成功!");public void cha ngePhysics(float physics)/修改学生物理成绩physics

21、Score = physics;Console.WriteLine(" 修改成功! ");/定义大学生类,继承中学生类class collegeStu : middleSchoolStustatic stri ng Stuld;定义一个私有的静态变量成员protected float computerScore;/构造函数public collegeStu(string stuName, string stuld, string stuSex, string stuAge, string stuNatPlace, string contactWay, float chine

22、seScore, float mathScore, float englishScore, float physicsScore, float chemistryScore, float computerScore): base(stuName, stuSex, stuAge, stuNatPlace, contactWay, chineseScore, mathScore, englishScore, physicsScore, chemistryScore)Stuld = stuld; /Stuld是静态属性,不能用this关键字puterScore = computerScore;/析构

23、函数collegeStu() /重写基类的方法,增加两个输入数据成员public override void input()base.i nput();/用base关键字访问基类的in put ()方法Console.Write("学号:");StuId = Console.ReadLine();Co nsole.Write(” 计算机:");computerScore = float.Parse(Console.ReadLine();new public void show()/new 关键字覆盖基类成员Con sole.WriteLi ne(” 学生基本信息:

24、");Console.WriteLine(": 0,学号: 1,性别: 2, 年龄: 3, 籍贯: 4, 联系方式: 5", StuName, StuId, StuSex, StuAge, StuNatPlace, contactWay);Con sole.WriteLi ne(” 学生成绩信息:");Console.WriteLine(”语文:0,数学:1,英语:2,物 理: 3, 化学: 4, 计算机: 5", ChineseScore,MathScore, englishScore, physicsScore ,chemistryScor

25、e, 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 stri ng getStuld()定义一个静态方法,获得学号return(Stuld);/静态方法访

26、问静态变量/定义带引用型和输出型参数的方法成员,包含的是数据的 存储地址public void searchStuld(ref stri ng ID, out int w)/ 查找学生学 号if (ID = getStuld() 访问静态方法w = 1;elsew = 0;public void changeComputer(float computer)修改学生计算机成绩computerScore = computer;Co nsole.WriteLi ne(” 修改成功!");class Program1.学生信息public static void fun ctio n()定义

27、一个静态方法,在主函数中 调用Console.WriteLine("*浏览;*、'); *、'、;删除;修改;Console.WriteLine("*");Console.WriteLine("*");Console.WriteLine("* *");static void Main(string args)Console.WriteLine("*用信息管理系统 *");3.学生信息4.学生信息0. 退 出 ;欢迎使用学生通Console.WriteLine();Con sole.Writ

28、e(”请选择要管理的学生类型(1.大学生,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,

29、0, 0, 0, 0, 0);/实例化对象(输入“ y”或者“ n”):生信息。 ", length + 1);作: ");");字符串类型转换为整型个元素, G 是类的对象,gi.input();Console.Write(”是0否继续录入信息 ");string m = Console.ReadLine();if (m = "n")break;length+;Console.WriteLine("您一共录入0个学Console.WriteLine();Con sole.WriteL in e("以下是系统基本操

30、Program.function();Console.WriteLine();Co nsole.Write(”请选择您要执行的操作:int a = int.Parse(Console.ReadLine();/将Console.WriteLine();if (a = 1)/使用 foreach 循环访问数组的每一 g 是对象数组foreach (collegeStu G in g)G.show();G.sumScore();else if (a = 2)string yn;doConsole.WriteLine("*");1. 按 学 生查找;Console.WriteLin

31、e("*");2. 按 学 生 学号查找;Console.WriteLine("*");0. 退出;Co nsole.Write(”请选择您要执行的操作: ");intint.Parse(Console.ReadLine();if (b = 1)Co nsole.Write("请输入要查找学生的: ");stringnameConsole.ReadLine();int w, j = 0;for (int i = 0; i <= length;name, out w);结果为0 个。", j);找学生的学号:

32、");Console.ReadLine();gi.searchStuName(refif (w = 1)gi.show();gi.sumScore(); j+;Console.WriteLine(" 找到的else if (b = 2)Co nsole.Write("请输入要查stringid=int w, j = 0;for (int i = 0; i <= length;gi.searchStuId(ref id,out w);if (w = 1)gi.show();gi.sumScore();j+;结果为0 个。", j);Console.W

33、riteLine(" 找到的elsebreak;Console.Write("是否继续查找(选择“y”或者“ n”):);yn = Console.ReadLine(); while (yn = "y");else if (a = 3)学生: ");Con sole.WriteLi ne(”请输入要删除的string name = Console.ReadLine(); for (int i = 0; i <= length; i+)if (name = gi.StuName)gi = gi + 1;Con sole.WriteLi ne

34、("删除成功!");else if (a = 4)Co nsole.Write(”请输入您要修改的学生:");string name = Console.ReadLine();int w;for (int i = 0; i <= length; i+)gi.searchStuName(ref name, outw);if (w = 1)gi.show();gi.sumScore();Console.WriteLine("*、'2. 修 改 学 生 成 绩 信 息 ;Console.WriteLine("*、'Co nsol

35、e.Write("请选择您要执行的操作: ");intint.Parse(Console.ReadLine();if (b = 1)Con sole.Write("您要修 改的部分是( 1.年龄, 2.籍贯,3.联系方式):");int choose = int.Parse(Console.ReadLine();switch (choose)case 1:Con sole.Write("您要将其年龄改为:");string age = Console.ReadLine();gi.changeStuAge(age);break; cas

36、e 2:Con sole.Write(”您要将其籍贯改为:");string nation = Console.ReadLine();gi.changeStuNatPlace(nation);break;case 3: Con sole.Write(”您要将其联系方式改为:");string conWay = Console.ReadLine();gi.changeStuNatPlace(conWay);break; default: break;gi.show(); gi.sumScore();elseCon sole.Write("您要修 改的成绩部分是( 1

37、.语文, 2.英语, 3.物理,4.计算机): ");int choose = int.Parse(Console.ReadLine();switch (choose)case 1:Co nsole.Write(”您要将其语文成绩改为:");float chinese = float.Parse(Console.ReadLine();gi.changeChinese(chinese);break; case 2:Con sole.Write("您要将其英语成绩改为:");float english = float.Parse(Console.ReadLi

38、ne();gi.changeEnglish(english);break; case 3:Co nsole.Write(”您要将其物理成绩改为:");floatphysics = float.Parse(Console.ReadLine();gi.changePhysics(physics);break;case 4:Con sole.Write("您要将其计算机成绩改为:");float computer = float.Parse(Console.ReadLine();gi.changeComputer(computer);break; default: br

39、eak;gi.show(); gi.sumScore();elseCon sole.WriteLi ne(”退出学生通用管 理系统! ");break;case 2:middleSchoolStu mid = new middleSchoolStu100;定义对象数组int length = 0;for (int i = 0; i <= length; i+)midi = new middleSchoolStu("0", "0", "0", "0", "0", 0, 0, 0,

40、0, 0);/ 实例化对象midi.input();Console.Write(”是0否继续录入信息 (输入“y”或者“ n”):");string m = Console.ReadLine();if (m = "n")break;length+;Console.WriteLine("您一共录入0个学 生信息。 ", length + 1);Console.WriteLine();Con sole.WriteL in e("以下是系统基本操 作: ");Program.function();Console.WriteLine

41、();Co nsole.Write(”请选择您要执行的操作:");int a = int.Parse(Console.ReadLine();Console.WriteLine();if (a = 1)foreach (middleSchoolStu M in mid)M.show();M.sumScore();else if (a = 2)string yn;do生的: ");Console.ReadLine();name, out w);Co nsole.Write("请输入要查找学stringnameint w, j = 0;for (int i = 0; i

42、 <= length; i+)midi.searchStuName(refif (w = 1)midi.show();midi.sumScore();j+;Console.Write("是否继续查找(选择“y”或者“ n”):");yn = Console.ReadLine(); while (yn = "y");else if (a = 3)Con sole.WriteLi ne(”请输入要删除的学生: ");string name = Console.ReadLine(); for (int i = 0; i <= length

43、; i+)if (name = midi.StuName)midi = midi + 1;Con sole.WriteLi ne("删除成功!");else if (a = 4)Co nsole.Write(”请输入您要修改的学生: ");string name = Console.ReadLine();int w;for (int i = 0; i <= length; i+)midi.searchStuName(ref name,out w);if (w = 1)midi.show();midi.sumScore();Console.WriteLine(

44、"*");1. 修 改 学 生 基 本 信 息 ;Console.WriteLine("*");2. 修 改 学 生 成 绩 信 息 ;Co nsole.Write("请选择您要执行的操作: ");intint.Parse(Console.ReadLine();if (b = 1)Con sole.Write("您要将其联系方式改为: ");string conWayConsole.ReadLine();midi.changeStuNatPlace(conWay);midi.show();其物理成绩改为: &quo

45、t;);float.Parse(Console.ReadLine();midi.changePhysics(physics);else理系统 !");midi.sumScore();elseCon sole.Write("您要将float physics =midi.show();midi.sumScore();Con sole.WriteLi ne(”退出学生通用管break;case 3:pupil pup = new pupil100;/ 定义对象数int length = 0;pupO = new pupil("美","女",

46、 "20", "", 98,97, 100);/*for (int i = 0; i <= length; i+)pupi = new pupil("0", "0", "0", "0", 0,0, 0);/实例化对象pupi.input();Console.Write(”是0否继续录入信息(输入“y”或者“ n”):");string m = Console.ReadLine();if (m = "n")break;length+;Cons

47、ole.WriteLine("您一共录入0个学生信息。 ", length + 1);*/Console.WriteLine();Con sole.WriteL in e("以下是系统基本操作: ");Program.function();Console.WriteLine();");Co nsole.Write(”请选择您要执行的操作:int a = int.Parse(Console.ReadLine();Console.WriteLine();if (a = 1)foreach (pupil P in pup)P.show();P.sum

48、Score();else if (a = 2)string yn;do生的: ");Console.ReadLine();name, out w);Co nsole.Write("请输入要查找学stringnameint w, j = 0;for (int i = 0; i <= length; i+)pupi.searchStuName(refif (w = 1)pupi.show();pupi.sumScore();j+;Console.Write("是否继续查找(选择“y”或者“ n”):");yn = Console.ReadLine();

49、 while (yn = "y");else if (a = 3)Con sole.WriteLi ne(”请输入要删除的学生: ");string name = Console.ReadLine(); for (int i = 0; i <= length; i+)if (name = pupi.StuName)pupi = pupi + 1;Con sole.WriteLi ne("删除成功!");else if (a = 4)Co nsole.Write(”请输入您要修改的学生: ");string name = Cons

50、ole.ReadLine();int w;for (int i = 0; i <= length; i+)pupi.searchStuName(ref name, out w);if (w = 1) pupi.show(); pupi.sumScore();Co nsole.Write("您要将其语 文成绩改为: ");floatchinese =float.Parse(Console.ReadLine();pupi.changeChinese(chinese);pupi.show(); pupi.sumScore();else理系统 !");Con sol

51、e.WriteLi ne(”退出学生通用管break;default:break;Console.WriteLine(”请按任意键结束此次操作.");Con sole.ReadKey();六、运行结果进入主界面选择大学生、中学生或小学生。1.选择大学生录入学生信息:中学主.:r3.小宇主):1以下是桑抚基4费作;卅时1”牛生信息制超;*卄卄叭"OtM-M M H KM-M-M M H HMM ttH H Mtt 2 -学主倍卫”芒砂J ; M KN M M H K NM M M M k MM N M H N K K *智MmMKVHWMMMIm« w 常禽生倩月除

52、:MWWW WN WWWWMM HWWWHMNW 学'生 信岗节1 页: WWW WM MVWWMMW N半;« N M W Of M N KM H M MW N fiilj"C:/U&er刘d刮阳OMFnts/visu引 studio JOI /Projects/stu demtlnfcwmtiionMnagemen-,管堪噸 西 -15沖対入 要婆李男起汀醐酣芜弍辭?&溯冷点 择入:机抽井 世鞘宕别龄片文学语系理学X時一 谓谓讎W年«慕英联物比学计是無旦下是系址基本操作;MKMM H養趕養廉芙浜餐翼黃養关柴关其共乂簧关餐是其餐餐:M:M

53、浜浜弄买汞芙岂其关梵共光芙MMMMKMM KM KMMM M 抚斗浜芙茨来浜芙疋转光芙光来KMMMMMM MM MMKM M进入浏览功能:I 一学卞咱慕旳乜: 2学宅V旦彗及; 盒学生棺恵删除: 学生熄息谬改; P 一退出:学土呈本店.4姓力 李阴,学J 2S151212.性和 暮年斷 却籍处 江西联鏡方式1ZMWT89昭 学生競绩弓E:丙文:込疲学:蚁英谄:X的理;站.化尝:很计耳机:9Q总成绩匕*<3£f平均分! 72.6G6G&晴选挥他要执行的操柞;2| . 垃学生堆名查益 £ MHMHMHMMMHMHMHMMMMM耗KKK推屛事E弼X弼:擁K弭乂弭魁擁

54、捧宾 2_|占学土.学 弓查线1HHmMMMMMMMMNMNM MM KM M £k 追出 MHMMMHMNMMMHMHMMMMMMMriMMMMMMM 诗起择傳翌矶厅曲拱作:1 诣粘入更在找学生的竝名:李明学生荃至信息E倉老:李明,学号:20151212:男,年龄:迪希粕 汀阿联龄方式:2咖&"沏 学生成缩信亘:语文z 9G,&学:禍.英砾氛物理:旳化学=他计算机匸90总我対:43&,平均芬:72.66666找到的结果为1个。區丕融绘售珅f比提"J M吿“n” I , n进入删除功能:诸喘择窓要执行的帯4勻3 清输入要型除的学生舛名;李明別除成功!r =k 4<r /-r ,3Sr ir* 1 -tr . I -k£L 8进入修改功能:谊肖擇躱賽扶L餉噪柞,題话敲LA佐姿修攻的学生姓名:李用兰主基本信息:屣客!李阴.学号 291訓石孔性呈肛舅,年鑿:甜籍贯:江西.联屋方式;123456Tfl301 事生成绩信息!谄处瞅玫关阳”英語:0用型阳,化学:冷计鉱机:90息成缜:彰&平均分:72 G66&6MKMMMKSKMMKNiifM-rtMMX-KiM F 係黃于

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论