-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentManager.cpp
More file actions
50 lines (46 loc) · 1.02 KB
/
Copy pathStudentManager.cpp
File metadata and controls
50 lines (46 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "StudentManager.h"
#include <iostream>
using namespace std;
int StudentManager::count = 0;
void StudentManager::showList(){
for(int i=0;i<count;i++){
cout<<"学号:"<<list[i]->getNo()<<" 姓名:"<<list[i]->getName()<<" 成绩"<<list[i]->getGrade()<<endl;
}
}
Student * StudentManager::input(){
int no;
string name;
cout<<"请输入学号:"<<endl;
cin>>no;
cout<<"请输入姓名:"<<endl;
cin>>name;
Student * result = new Student(no,name);
return result;
}
void StudentManager::addStudent(){
Student * newone = input();
list[count] = newone;
count ++;
}
void StudentManager::delStudent(){
Student * del = input();
int index = find(del);
if(-1!=index){
list[index] = list[count];
count--;
}
}
int StudentManager::find(Student * clue){
for(int i=0;i<count;i++){
if(clue->getName()==list[i]->getName()) return i;
}
return -1;
}
void StudentManager::setGrade(int no,int grade){
int i;
for(i=0;i<count;i++){
if(no==list[i]->getNo())break;
}
if(i>=0&&i<count)list[i]->setGrade(grade);
else cout<<"查无此人!"<<endl;
}