-
Notifications
You must be signed in to change notification settings - Fork 1
/
13-5Student_info.h
48 lines (38 loc) · 1.15 KB
/
13-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
42
43
44
45
46
47
48
#ifndef GUARD_Student_info
#define GUARD_Student_info
// Student_info.h header file
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <string>
#include "grade.h"
#include "core.h"
// Handle class for Core and Grad classes
class Student_info {
public:
Student_info(): cp(0) { }
Student_info(std::istream& is): cp(0) { read(is); }
Student_info(const Student_info&);
Student_info& operator=(const Student_info&);
~Student_info() { delete cp; }
std::istream& read(std::istream&);
std::string name() const {
if (cp) return cp->name();
else throw std::runtime_error("uninitialized Student");
}
double grade() const {
if (cp) return cp->grade();
else throw std::runtime_error("uninitialized Student");
}
std::string letter(double g) const { return cp->letter(g); }
bool valid() const { return cp->valid(); }
static bool compare(const Student_info& s1,
const Student_info& s2) {
return s1.name() < s2.name();
}
private:
Core* cp;
};
std::istream& read_hw(std::istream&, std::vector<double>&);
#endif //GUARD_Student_info