Teacher.cpp 1.98 KB
Newer Older
Andrew Binder's avatar
Andrew Binder committed
1
#include "Teacher.h"
Andrew Binder's avatar
Andrew Binder committed
2
#include <iostream>
Andrew Binder's avatar
Andrew Binder committed
3
4
5

Teacher::Teacher(string userNameIn) {
    userName = userNameIn;
Andrew Binder's avatar
Andrew Binder committed
6
7
8
}

void Teacher::displayMenu() {
Andrew Binder's avatar
Andrew Binder committed
9
10
    cout << "Teacher Menu" << endl;
    cout << "____________" << endl;
Andrew Binder's avatar
Andrew Binder committed
11
12
13
14
15
16
17
18
19
20
}

void Teacher::displayProgress() {
    cout << "------STUDENT GRADEBOOK------\n";
    cout << "Student\t\tCurrent Level\n";
    for (int i = 0; i < roster.size(); i++) { 
        cout << roster.at(i).getUserName() << "\t\t" << roster.at(i).getLevel() << endl;
    }
}

Andrew Binder's avatar
Andrew Binder committed
21
void Teacher::exportProgress() {
Andrew Binder's avatar
Andrew Binder committed
22
23
24
    
}

Andrew Binder's avatar
Andrew Binder committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
void Teacher::enrollStudent(Student studentIn) {
    bool validName = 1;
    for (int i = 0; i < roster.size(); i++) {
        if (roster.at(i).getUserName() == studentIn.getUserName()) {
            validName = 0;
        }
    }
    
    if (validName) {
        roster.push_back(studentIn);
        cout << "Student succesfully enrolled." << endl;
    } else {
        cout << "Error: Student already exists!" << endl;
    }
    
    
    
Andrew Binder's avatar
Andrew Binder committed
42
43
}

Andrew Binder's avatar
Andrew Binder committed
44
45
46
47
48
49
50
51
52
53
54
55
void Teacher::adjustProgress(string studentUserNameIn, int level) {
    int 
        lastLevel = -1,
        studentNumber = -1;
    bool validName = 0;
    
    for (int i = 0; i < roster.size(); i++) {
        if (roster.at(i).getUserName() == studentUserNameIn) {
            validName = 1;
            studentNumber = i;
        }
    }
Andrew Binder's avatar
Andrew Binder committed
56
    
Andrew Binder's avatar
Andrew Binder committed
57
58
59
60
61
62
63
64
    if (validName) {
        lastLevel = roster.at(studentNumber).getLevel();
        roster.at(studentNumber).setLevel(level);
        cout << roster.at(studentNumber).getUserName() << "'s level was changed from level " << lastLevel << " to " << roster.at(studentNumber).getLevel() << "." << endl;
    } else {
        cout << "Error: Student not found!" << endl;
    }

Andrew Binder's avatar
Andrew Binder committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
}

void Teacher::endProgram() {

}

// Accessors
const string Teacher::getUserName() {
    return userName;
}

const string Teacher::getExitCode() {
    return exitCode;
}

// Mutators
Andrew Binder's avatar
Andrew Binder committed
81
void Teacher::setExitCode(string exitCodeIn) {
Andrew Binder's avatar
Andrew Binder committed
82
83
84
    exitCode = exitCodeIn;
}

Andrew Binder's avatar
Andrew Binder committed
85
void Teacher::setUserName(string userNameIn) {
Andrew Binder's avatar
Andrew Binder committed
86
    userName = userNameIn;
Andrew Binder's avatar
Andrew Binder committed
87
}