| 查看: 624 | 回复: 5 | |||
paopao1122铜虫 (小有名气)
|
[交流]
【求助】请求帮忙编个小程序【已完结】 已有5人参与
|
|
用类来管理学生教师档案:建立student(学生)及teacher(教师)类。假定这几个类各自具有的数据成员如下: student(学生)类:姓名,性别,年龄,学号,系别,年级; teacher(教师)类:姓名,性别,年龄,职称,担任课程,是否为研究生导师; 要求:每个类设立构造函数以及显示类对象数据的成员函数Display(),对对象的赋值成员函数(即重载运算符=)。对学生类还需要得到学生姓名的成员函数Getname(),学号的成员函数Getid();对教师类需要得到教师姓名的成员函数Getname(),职称的成员函数GetprofesionalTitle()。而后编制简单的main()函数,创建相关的类对象,对其类成员函数进行简单调用。 [ Last edited by 余泽成 on 2010-9-7 at 17:31 ] |
» 猜你喜欢
参与限项
已经有3人回复
假如你的研究生提出不合理要求
已经有7人回复
实验室接单子
已经有4人回复
全日制(定向)博士
已经有4人回复
对氯苯硼酸纯化
已经有3人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有12人回复
不自信的我
已经有12人回复
所感
已经有4人回复
要不要辞职读博?
已经有7人回复
北核录用
已经有3人回复
pwzhou
铁杆木虫 (正式写手)
- 应助: 51 (初中生)
- 金币: 7551.4
- 散金: 13
- 红花: 14
- 帖子: 412
- 在线: 316.9小时
- 虫号: 56225
- 注册: 2005-01-07
- 性别: GG
- 专业: 化学动力学
2楼2010-07-03 20:18:06
dolphin2008
金虫 (小有名气)
- 应助: 3 (幼儿园)
- 金币: 603.5
- 散金: 6
- 红花: 2
- 帖子: 275
- 在线: 93.8小时
- 虫号: 417874
- 注册: 2007-07-02
- 性别: GG
- 专业: 化学反应工程
★ ★ ★
paopao1122(金币+1):谢谢参与
resonant(金币+2):奖励应助:-) 2010-07-04 20:19:46
paopao1122(金币+38):非常感谢 2010-07-05 09:38:03
paopao1122(金币+1):谢谢参与
resonant(金币+2):奖励应助:-) 2010-07-04 20:19:46
paopao1122(金币+38):非常感谢 2010-07-05 09:38:03
|
这是用c#写的, using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Collections; namespace Test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } ArrayList TeacherArray = new ArrayList(); ArrayList StudentArray = new ArrayList(); private void button1_Click(object sender, EventArgs e) { teacher teacher1 = new teacher("teacher1" ;teacher teacher2 = new teacher("teacher2" ;TeacherArray.Add(teacher1.getname); TeacherArray.Add(teacher2.getname); student student1 = new student("student1" ;student student2 = new student("student2" ;StudentArray.Add(student1.getname); StudentArray.Add(student2.getname); teacher1.settitle = "Professor"; student1.setstudentID = "00001"; textBox1.Text ="Teacher.Name:" + teacher1.getname +", "+ "Teacher.Title:" + teacher1.gettitle + "; " + " Student.Name:" + student1.getname +", "+ "Student.ID:" + student1.getstudentID+"; "; Display(); } public void Display() { int totalTeacher = TeacherArray.Count; int totalstudent = StudentArray.Count; String[] displayteacher=new String[totalTeacher]; String[] displaystudent = new String[totalstudent]; TeacherArray.CopyTo(displayteacher); StudentArray.CopyTo(displaystudent); for (int i = 0; i textBox2.Text += displayteacher.ToString() + " "; } for (int i = 0; i < totalstudent; i++) { textBox2.Text += displaystudent.ToString() + " "; } } } public partial class teacher { public string name; public string sex; public int age; public string title; public string course; public Boolean IsTutor; public teacher() { } public teacher(string localName) { name = localName; } public string setname { set { name = value; } } public string getname { get { return name; } } public string settitle { set { title = value; } } public string gettitle { get { return title; } } } public partial class student { public string name; public string sex; public int age; public string studentID; public string department; public string grade; public student() { } public student(string localname) { name = localname; } public string setname { set { name = value; } } public string getname { get { return name; } } public string setstudentID { set { studentID = value; } } public string getstudentID { get { return studentID; } } } } [ Last edited by dolphin2008 on 2010-7-4 at 10:28 ] |

3楼2010-07-04 09:40:10
tjpm
金虫 (正式写手)
- 应助: 0 (幼儿园)
- 金币: 1025.7
- 散金: 10
- 红花: 1
- 帖子: 367
- 在线: 19.3小时
- 虫号: 717334
- 注册: 2009-03-07
- 专业: 凝聚态物性 II :电子结构
4楼2010-07-05 22:56:43

5楼2010-07-06 08:36:49
paopao1122
铜虫 (小有名气)
- 应助: 0 (幼儿园)
- 金币: 165.5
- 散金: 29
- 红花: 1
- 帖子: 80
- 在线: 6.6小时
- 虫号: 943649
- 注册: 2010-01-16
- 性别: MM
- 专业: 应用光学
6楼2010-09-07 16:07:23












回复此楼
;