-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent.cpp.txt
89 lines (71 loc) · 1.47 KB
/
student.cpp.txt
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "student.h"
int Mystrlen(char *c)
{
int size = 0;
while(c[size] != '\0')
size++;
return size + 1;
}
int MyStrcmp(char *c1, char *c2)
{
int len = Mystrlen(c1) < Mystrlen(c2) ? Mystrlen(c1) : Mystrlen(c2);
for(int i = 0; i < len; i++)
{
if(c1[i] < c2[i])
return -1;
if(c1[i] > c2[i])
return 1;
}
if(Mystrlen(c1) < Mystrlen(c2))
return -1;
if(Mystrlen(c1) > Mystrlen(c2))
return 1;
return 0;
}
void Mystrcpy(char *c1, char *c2)
{
for(int i = 0; i < Mystrlen(c2); i++)
{
c1[i] = c2[i];
}
c1[Mystrlen(c2)] = '\0';
}
char* Student::GetName()
{
char *nm = new char[50];
Mystrcpy(nm, this->name);
return nm;
}
void Student::SetName(const char *newName)
{
Mystrcpy(this->name, (char*)newName);
}
float Student::GetMathGrade()
{
return this->Grades[0];
}
void Student::SetMathGrade(float newGrade)
{
this->Grades[0] = newGrade;
}
float Student::GetEnglishGrade()
{
return this->Grades[1];
}
void Student::SetEnglishGrade(float newGrade)
{
this->Grades[1] = newGrade;
}
float Student::GetHistoryGrade()
{
return this->Grades[2];
}
void Student::SetHistoryGrade(float newGrade)
{
this->Grades[2] = newGrade;
}
float Student::GetAvarage()
{
float sum = this->Grades[0] + this->Grades[1] + this->Grades[2];
return sum / 3;
}