/
11-5Student_info.h
41 lines (35 loc) · 1.16 KB
/
11-5Student_info.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
#ifndef GUARD_Student_info
#define GUARD_Student_info
// Student_info.h header file
#include <iostream>
#include <string>
#include <vector>
#include "grade.h"
#include <algorithm>
using std::find;
using std::cout;
using std::endl;
// Created class Student_info Ch. 9
class Student_info {
public:
Student_info(): midterm(0), final(0) { cout << "Default constructor" << endl; }
Student_info(std::istream& is) { read(is); cout << "Read constructor" << endl; }
Student_info(const Student_info& s) {
n = s.n; midterm = s.midterm; final = s.final; homework = s.homework;
cout << "Copy constructor" << endl;
}
std::string name() const { return n; }
bool valid() const { return !homework.empty(); }
std::istream& read(std::istream&);
double grade() const;
double agrade() const;
double ograde() const;
bool did_all_hw(){ return ((find(homework.begin(), homework.end(), 0)) == homework.end()); }
private:
std::string n;
double midterm, final;
std::vector<double> homework;
};
bool compare(const Student_info&, const Student_info&);
std::istream& read_hw(std::istream&, std::vector<double>&);
#endif //GUARD_Student_info