-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent.cpp
81 lines (66 loc) · 2.94 KB
/
student.cpp
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
/***************************************************************************************************
** Author: Michael Johnson
** Date: 7/19/2017
** Description: Definitions of Student class functions
***************************************************************************************************/
#include "Student.h"
/*******************************************************************************************************
** Student Default Constructor
** Constructs the object with empty variables
*******************************************************************************************************/
Student::Student() : People()
{
studentName = "";
studentAge = 0;
studentGPA = 0.0;
}
/*******************************************************************************************************
** Student Constructor
** Constructs the object with user input for each variable
*******************************************************************************************************/
Student::Student(string n, int a, double g) : People(n, a, g)
{
studentName = n;
studentAge = a;
studentGPA = g;
}
/*******************************************************************************************************
** Student destructor
** Destructs the object
*******************************************************************************************************/
Student::~Student()
{
}
/*******************************************************************************************************
** getName function
** returns the name of student variable
*******************************************************************************************************/
string Student::getName()
{
return this->studentName;
}
/*******************************************************************************************************
** getAge function
** returns the age of student variable
*******************************************************************************************************/
int Student::getAge()
{
return this->studentAge;
}
/*******************************************************************************************************
** getScore function
** returns the score of student variable
*******************************************************************************************************/
double Student::getScore()
{
return this->studentGPA;
}
/*******************************************************************************************************
** do_work function
** creates a random number between 1 and the user input and stores it
*******************************************************************************************************/
void Student::do_work(int x)
{
hoursWorked = rand() % x + 1;
cout << getName() << " did " << hoursWorked << " hours of homework." << endl;
}