一、问题提出: 1.创建相应的成员变量保存学生基本信息。 2.创建相应属性和索引以实现对成员变量访问的封装。 3.创建相应的方法以实现对学生基本信息的管理。 4.创建相应的方法以实现对学生成绩的管理。 5.派生出小学生,中学生,大学生等子类。 二、问题分析: 1、添加基类Student,定义私有成员变量姓名,性别,号,民族,住址,英语,数学,语文等学生的基本信息并创建相应的属性实现对成员变量访问的封装。 2、分别定义派生类Pupil,CollegeStudenr,Middleschoolstudent,并使用base关键字调用基类构造函数。 3、添加Option类实现对学生信息进行的一系列操作。 4、添加Manager类实现管理用户登陆。 三、程序代码: Student.cs: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentInformation public class Student private string studentType; public string StudentType getreturn studentType; setstudentType=value; private string studentName; public string StudentName get return studentName; set studentName = value; private string studentSex; public string StudentSex get return studentSex; set studentSex = value; private string studentNumber; public string StudentNumber get return studentNumber; set studentNumber = value; private string studentNation; public string StudentNation get return studentNation; set studentNation = value; private string studentAddress; public string StudentAddress get return studentAddress; set studentAddress = value; private string englishScore; public string EnglishScore get return englishScore; set englishScore = value; private string mathScore; public string MathScore get return mathScore; set mathScore = value; private string chineseScore; public string ChineseScore get return chineseScore; set chineseScore = value; public Student(string type,string name,string sex,string number,string nation,string address,string english,string math,string chinese) this.studentType=type; this.studentName=name; this.studentSex=sex; this.studentNumber=number; this.studentNation=nation; this.studentAddress=address; this.englishScore=english; this.mathScore=math; this.chineseScore=chinese; public void showstudent() Console.WriteLine("该同学的基本信息为:"); Console.WriteLine("学生类型:" studentType); Console.WriteLine("姓名:" studentName); Console.WriteLine("性别:" studentSex); Console.WriteLine("学号:" studentNumber); Console.WriteLine("住址:" studentAddress); Console.WriteLine("英语:" englishScore); Console.WriteLine("数学:" mathScore); Console.WriteLine("语文:" chineseScore); Option.cs: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentInformation public class Option : Student int flag; public Option(string Type, string Name, string Sex, string Number, string Nation, string Address, string English, string Math, string Chinese) : base(Type, Name, Sex, Number, Nation, Address, English, Math, Chinese) Console.WriteLine("对学生信息进行相关的操作"); public void input() Console.WriteLine("请输入一系列的相关信息"); StudentName = Console.ReadLine(); StudentSex = Console.ReadLine(); StudentNumber = Console.ReadLine(); StudentNation = Console.ReadLine(); StudentAddress = Console.ReadLine(); EnglishScore = Console.ReadLine(); MathScore = Console.ReadLine(); ChineseScore = Console.ReadLine(); public void search_number(string numm) flag = 0; if (StudentNumber == numm) Console.WriteLine(StudentNumber "被找到"); flag = 1; public void search_name(string nname) flag = 0; if (StudentName == nname) Console.WriteLine(StudentName "被找到"); flag = 1; public void input_englishScore() Console.WriteLine("请重新输入英语成绩"); string englishScore = Console.ReadLine(); this.EnglishScore = englishScore; public void input_chineseScore() Console.WriteLine("请重新输入语文成绩"); string chineseScore = Console.ReadLine(); this.ChineseScore = chineseScore; public void input_mathScore() Console.WriteLine("请重新输入数学成绩"); string mathScore = Console.ReadLine(); this.MathScore = mathScore; public int getflag() return flag; Middleschoolstudent.cs: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentInformation public class Middleschoolstudent:Option public Middleschoolstudent(string Type, string Name, string Sex, string Number, string Nation, string Address, string English, string Math, string Chinese) : base(Type, Name, Sex, Number, Nation, Address, English, Math, Chinese) StudentType = "中学生"; Program.cs: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentInformation class Program int number, judge = 0, flag, choose = 0; static void Main(string[] args) int i, j, n = 0, t = 0, k = 0; string find_name, find_number, delet_number, judgestring; Console.WriteLine("***********欢迎使用通用学生管理系统 *************"); Console.WriteLine("请输入用户名:"); string username = Console.ReadLine(); manager ma = new manager(); ma.Next = username; if (ma.load()) Console.WriteLine(" ************************ "); Console.WriteLine(" 通用学生信息管理系统 "); Console.WriteLine(" ************************ "); Console.WriteLine(" 1.录入基本信息 "); Console.WriteLine(" 2.删除信息 "); Console.WriteLine(" 3.修改基本信息 "); Console.WriteLine(" 4.查询基本信息 "); Console.WriteLine(" 5.打印信息 "); Console.WriteLine(" ************************ "); Console.WriteLine(" 欢迎使用 "); Console.WriteLine(" ************************ "); Console.WriteLine(""); Console.WriteLine("请选择学生类型:"); Console.WriteLine("1.大学生"); Console.WriteLine("2.中学生"); Console.WriteLine("3.小学生"); CollegeStudent[] g = new CollegeStudent[100]; Middleschoolstudent[] m = new Middleschoolstudent[100]; Pupil[] s = new Pupil[100]; int choose = int.Parse(Console.ReadLine()); switch (choose) case 1: do Console.WriteLine("请输入你要选择执行的功能:"); int number1 = int.Parse(Console.ReadLine()); int judge = 0; switch (number1) case 1: i = 0; do g[i] = new CollegeStudent("0", "0", "0", "0", "0", "0", "0", "0", "0"); g[i].input(); i ; n ; Console.WriteLine(" 是否继续 录入档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); Console.WriteLine("共录入" n "人"); break; //录入 case 2: do t = 0; judge = 0; Console.WriteLine("请输入您要 删除的学号"); delet_number = Console.ReadLine(); for (i = 0; i g[i].search_number(delet_number); if (g[i].getflag() == 1) for (j = i; j g[j] = g[j 1]; n--; t ; Console.WriteLine("正 在删除"); Console.WriteLine("删 除成功"); if (t == 0) Console.WriteLine("您删除 的学生的学生学号不存在"); Console.WriteLine("是否继续删 除是1否2"); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; //删除 case 3: Console.WriteLine(" **************************************** "); Console.WriteLine(" 通用 学生信息管理系统修改 "); Console.WriteLine(" **************************************** "); Console.WriteLine(" 1.英语 "); Console.WriteLine(" 2.数学 "); Console.WriteLine(" 3.语文 "); do Console.WriteLine("请输入你要选择执行的功能:"); int number2 = int.Parse(Console.ReadLine()); switch (number2) case 1: do t = 0; judge = 0; Console.WriteLine("请输入你要修改的英语成绩的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; i g[i].search_number(find_number); if (g[i].getflag() == 1) g[i].input_englishScore(); t ; if (t == 0) Console.WriteLine("您查找的人不在"); Console.WriteLine(" 是否继续录入档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 2: do t = 0; judge = 0; Console.WriteLine("请输入你要修改的数学成绩的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; i g[i].search_number(find_number); if (g[i].getflag() == 1) g[i].input_mathScore(); t ; if (t == 0) Console.WriteLine("您查找的人不在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 3: do t = 0; judge = 0; Console.WriteLine("请输入你要修改的语文成绩的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; i g[i].search_number(find_number); if (g[i].getflag() == 1) g[i].input_chineseScore(); t ; if (t == 0) Console.WriteLine("您查找的人不在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; //修改 case 4: Console.WriteLine(" **************************************** "); Console.WriteLine(" 通用学生信息管理查询 "); Console.WriteLine(" **************************************** "); Console.WriteLine(" 1.学号 "); Console.WriteLine(" 2.姓名 "); do Console.WriteLine("请输入你要选择执行的功能:"); int number2 = int.Parse(Console.ReadLine()); switch (number2) case 1: do t = 0; judge = 0; Console.WriteLine("请输入你要查找的学生的学号:"); Console.ReadLine(); for (i = 0; i if (g[i].getflag() == 1) g[i].showstudent(); t ; if (t == 0) Console.WriteLine("您要找的学号不存在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 2: do t = 0; judge = 0; Console.WriteLine("请输入你要查找的学生的姓名:"); find_name = Console.ReadLine(); for (i = 0; i if (g[i].getflag() == 1) g[i].showstudent(); if (t == 0) Console.WriteLine("您要找的姓名不存在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; Console.WriteLine(" 是否继续其他查询方案档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 5: for (i = 0; i g[i].showstudent(); break; Console.WriteLine(" 是否继续其他查询方案档案?是1.否2."); judgestring = Console.ReadLine(); while (judgestring == "1"); break; case 2: do Console.WriteLine("请输入你要选择执行的功能: "); int number1 = int.Parse(Console.ReadLine()); int judge = 0; switch (number1) case 1: i = 0; do m[i] = new Middleschoolstudent("0", "0", "0", "0", "0", "0", "0", "0", "0"); m[i].input(); i ; n ; Console.WriteLine(" 是否继续 录入档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); Console.WriteLine("共录入" n "人"); break; //录入 case 2: t = 0; judge = 0; Console.WriteLine("请输入您要删除的学号"); delet_number = Console.ReadLine(); for (i = 0; i m[i].search_number(delet_number); if (m[i].getflag() == 1) for (j = i; j m[j] = m[j 1]; n--; t ; Console.WriteLine("正在删除"); Console.WriteLine("删除成功"); if (t == 0) Console.WriteLine("您删除的学生的学生学号不存在"); Console.WriteLine("是否继续删除是1否2"); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; //删除 case 3: Console.WriteLine(" *************************************** "); Console.WriteLine(" 通用学生信息管理修改 "); Console.WriteLine(" **************************************** "); Console.WriteLine(" 1.英语 "); Console.WriteLine(" 2.数学 "); Console.WriteLine(" 3.语文 "); do Console.WriteLine("请输入你要选择执行的功能:"); int number2 = int.Parse(Console.ReadLine()); switch (number2) case 1: do t = 0; judge = 0; Console.WriteLine("请输入你要修改的英语成绩的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; i m[i].search_number(find_number); if (m[i].getflag() == 1) m[i].input_englishScore(); if (t == 0) Console.WriteLine("您查找的人不在"); Console.WriteLine(" 是否继续录入档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 2: do t = 0; judge = 0; Console.WriteLine("请输入你要修改的数学成绩的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; im[i].search_number(find_number); if (m[i].getflag() == 1) m[i].input_mathScore(); if (t == 0) Console.WriteLine("您查找的人不在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 3: do t = 0; judge = 0; Console.WriteLine("请输入你要修改的语文成绩的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; im[i].search_number(find_number); if (m[i].getflag() == 1) m[i].input_chineseScore(); if (t == 0) Console.WriteLine("您查找的人不在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; //修改 case 4: Console.WriteLine(" **************************************** "); Console.WriteLine(" 通用学生信息管理查询 "); Console.WriteLine(" **************************************** "); Console.WriteLine(" 1.学号 "); Console.WriteLine(" 2. 姓名 "); do Console.WriteLine("请输入你要选择执行的功能:"); int number2 = int.Parse(Console.ReadLine()); switch (number2) case 1: do t = 0; judge = 0; Console.WriteLine("请输入你要查找的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; i if (m[i].getflag() == 1) m[i].showstudent(); t ; if (t == 0) Console.WriteLine("您要找的学号不存在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 2: do t = 0; judge = 0; Console.WriteLine("请输入你要查找的学生的姓名:"); find_name = Console.ReadLine(); for (i = 0; i if (m[i].getflag() == 1) m[i].showstudent(); t ; if (t == 0) Console.WriteLine("您要找的姓名不存在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; Console.WriteLine(" 是否继续 其他查询方案档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 5: for (i = 0; i m[i].showstudent(); break; Console.WriteLine(" 是否继续其他查询方案档 案?是1.否2."); judgestring = Console.ReadLine(); while (judgestring == "1"); break; case 3: do Console.WriteLine("请输入你要选择执行的功能:"); int number1 = int.Parse(Console.ReadLine()); int judge = 0; switch (number1) case 1: i = 0; do s[i] = new Pupil("0", "0", "0", "0", "0", "0", "0", "0", "0"); s[i].input(); i ; n ; Console.WriteLine(" 是否继续 录入档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); Console.WriteLine("共录入" n "人"); break; //录入 case 2: do t = 0; judge = 0; Console.WriteLine("请输入您要删除的学号"); delet_number = Console.ReadLine(); for (i = 0; i s[i].search_number(delet_number); if (s[i].getflag() == 1) for (j = i; j s[j] = s[j 1]; n--; t ; Console.WriteLine("正在删除"); Console.WriteLine("删除成功"); if (t == 0) Console.WriteLine("您删除的学生的学生学号不存在"); Console.WriteLine("是否继续删除是1否2"); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; //删除 case 3: Console.WriteLine(" ***************************************** "); Console.WriteLine(" 通用学生信息管理修改 "); Console.WriteLine(" ***************************************** "); Console.WriteLine(" 1.英语 "); Console.WriteLine(" 2.数学 "); Console.WriteLine(" 3.语文 "); do Console.WriteLine("请输入你要选择执行的功能:"); int number2 = int.Parse(Console.ReadLine()); switch (number2) case 1: do t = 0; judge = 0; Console.WriteLine("请输入你要修改的英语成绩的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; i s[i].search_number(find_number); if (s[i].getflag() == 1) s[i].input_englishScore(); t ; Console.WriteLine("您查找的人不在"); Console.WriteLine(" 是否继续录入档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 2: do t = 0; judge = 0; Console.WriteLine("请输入你要修改的数学成绩的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; i s[i].search_number(find_number); if (s[i].getflag() == 1) s[i].input_mathScore(); t ; if (t == 0) Console.WriteLine("您查找的人不在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); 1); break; case 3: do t = 0; judge = 0; Console.WriteLine("请输入你要修改的语文成绩的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; i s[i].search_number(find_number); if (s[i].getflag() == 1) s[i].input_chineseScore(); t ; if (t == 0) Console.WriteLine("您查找的人不在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; Console.WriteLine(" 是否继续 档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; //修改 case 4: Console.WriteLine(" **************************************** "); Console.WriteLine(" 通用学生信息管理查询 "); Console.WriteLine(" ***************************************** "); Console.WriteLine(" 1.学号 "); Console.WriteLine(" 2.姓名 "); do Console.WriteLine("请输入你要选择执行的功能:"); int number2 = int.Parse(Console.ReadLine()); switch (number2) case 1: do t = 0; judge = 0; Console.WriteLine("请输入你要查找的学生的学号:"); find_number = Console.ReadLine(); for (i = 0; i if (s[i].getflag() == 1) s[i].showstudent(); t ; if (t == 0) Console.WriteLine("您要找的学号不存在"); Console.WriteLine(" 是否继续档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 2: do t = 0; judge = 0; Console.WriteLine("请输入你要查找的学生的姓名:"); find_name = Console.ReadLine(); for (i = 0; i if (s[i].getflag() == 1) s[i].showstudent(); t ; if (t == 0) Console.WriteLine("您要找的姓名不存在"); Console.WriteLine(" 是否继续档案?是1.否2."); int.Parse(Console.ReadLine()); while (judge == 1); break; Console.WriteLine(" 是否继续其他查询方案档案?是1.否2."); judge = int.Parse(Console.ReadLine()); while (judge == 1); break; case 5: for (i = 0; i s[i].showstudent(); break; Console.WriteLine(" 是否继续其他查询方案档案?是1.否2."); judgestring = Console.ReadLine(); while (judgestring == "1"); break;
信息发布:广州名易软件有限公司 http://www.myidp.net
|