This repository was archived by the owner on May 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent.h
More file actions
119 lines (104 loc) · 2.53 KB
/
student.h
File metadata and controls
119 lines (104 loc) · 2.53 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#pragma once
#include "inc.h"
class Student {
string name_, surname_;
vector <int> nd_;
vector <int> median_;
int egz_;
//setteriai
void name(string);
void surname(string);
void nd(vector<int>);
void egz(int);
public:
//konstruktoriai
Student();
Student(string, string, vector<int>, int);
Student(const Student&);
//desktruktorius
~Student();
//getteriai
const string getName();
const string getSurname();
const vector<int> getNd();
const int getEgz();
//metodai
Student& operator=(const Student&);
void studEdit(string, string, vector<int>, int);
};
void Student::name(string temp){name_=temp;}
void Student::surname(string temp){surname_=temp;}
void Student::nd(vector<int> temp){nd_=temp;}
void Student::egz(int temp){egz_=temp;}
Student::Student() {
name(" ");
surname(" ");
nd({0});
egz(0);
}
Student::Student(const Student &temp) {
this->name(temp.name_);
this->surname(temp.surname_);
this->nd(temp.nd_);
this->egz(temp.egz_);
}
Student::Student(string y, string p, vector<int> a, int e) {
name(y);
surname(p);
nd(a);
egz(e);
}
Student::~Student(){name_=""; surname_= ""; nd_.clear();}
const string Student::getName() {
return name_;
}
const string Student::getSurname() {
return surname_;
}
const vector<int> Student::getNd() {
return nd_;
}
const int Student::getEgz() {
return egz_;
}
Student& Student::operator=(const Student& kint) {
if (this != &kint) {
name_ = kint.name_;
surname_ = kint.surname_;
nd_ = kint.nd_;
egz_ = kint.egz_;
median_ = kint.nd_;
}
return *this;
}
void Student::studEdit(string y, string p, vector<int> a, int e) {
name(y);
surname(p);
nd(a);
egz(e);
}
double getAverage(vector<int> const& v) {
return accumulate(v.begin(), v.end(), 0.0) / v.size();
// sudeda vektoriaus elementus nuo pradzios (v.begin) iki pabaigos (v.end) ir padalina is vektoriaus elemento kiekio (v.size)
}
double getMedian(vector<int> median) { //medianos algoritmas
size_t size = median.size();
sort(median.begin(), median.end());
if (size % 2 == 0)
{
return (median[size / 2 - 1] + median[size / 2]) / 2;
}
else
{
return median[size / 2];
}
}
/*
template <typename S>
ostream& operator<<(ostream& os, const vector<S>& vector) {
//spausdinam vektoriu elementus su cout <<, skirtas testavimui.
for (auto element : vector) {
os << element << " ";
}
return os;
}*/