-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCursist.h
83 lines (61 loc) · 3.34 KB
/
Cursist.h
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
#ifndef CURSIST_H
#define CURSIST_H
#include "structs.h" // Student and CPPGroup structs
#include <fstream> // std::ifstream
#include <vector> // std::vector
#include <string> // std::string
#include <sstream> // std::istringstream
#include <iostream> // std::cout
#include <iomanip> // std::put_time
#include <cmath> // std::round
class Cursist
{
std::ifstream d_inStudents; // Input file stream Students
std::ifstream d_inResults; // Input file stream Results
std::ofstream d_outStudents;// Output file stream Students
std::ofstream d_outResults; // Output file stream Results
std::vector<CPPGroup> d_groups; // Vector of CPPGroups
bool d_initialSkip; // Skip the first lines of the input file
std::string d_lineBuffer; // Buffer for the line
std::vector<Student> d_studentsBuffer; // Buffer for the students
int d_idBoxCounter; // Counter for the id box
bool d_groupFlag; // Flag for the group
bool d_extranotesFlag; // Flag for the extranotes
size_t d_numberOfParticipants; // Number of participants
CPPGroup d_groupofStudentBuffer;// Buffer for the group of the student
bool d_groupFound; // Flag for the group found
std::string d_tempGrades; // Buffer for the grades
public:
Cursist(); // Constructor
~Cursist() {}; // Destructor
void runCursist(int arg, char **argv); // Run the cursist program
private:
void getGroups(); // Get the group information from students
void groupsPrinter(); // Print the groups to the console
void studentsFileParser(); // Parse the students from the line
void parseStudents(std::istringstream &iss); // Parse the line
void outputStudents(); // Output the refreshed students to the output file
void outputStudentsHelper(); // Helper function for outputStudents
// Check the group of the student
std::vector<std::string> checkGroup(std::vector<Student> &students);
bool resultsField(std::string &input); // check if line is a results field
void outputResults(); // Output the new results to the output file
void outputResultsHelper(); // Helper function for outputResults
void addPercentages(); // Add the percentages to the output file
void addQuestionNumberings(); // Add the question numberings to the output file
void addRatings(); // Add the ratings to the output file
void addExerciseTypes(); // Add the exercise types to the output file
void getGradeofStudent(); // Get the group of the student
void addTenths(); // Add the tenths to the output file
void addNumberRatings();
std::vector<std::string> findGradesofStudent(Student student); // Find the grade of the student
std::string filterBest(std::vector<std::string> &students); // Filter the best students
void swapFilesStudents();// Swap the input and output files for students
void swapFilesResults(); // Swap the input and output files for results
// Check if string is a single repeated char
bool singleRepeatedChar(std::string &input);
// Get the number of participants from the line
void getNumberofParticipants(std::string &input);
size_t ghostParticipants(); // Get the number of ghost participants
};
#endif // CURSIST_H