59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#include "Student.hpp"
|
|
|
|
Student::Student() : number(0), name(""), isAnyName(true), isAnyNumber(true) {};
|
|
|
|
Student::Student(const int _number, const std::string _name) : number(_number), name(_name), isAnyNumber(false), isAnyName(false) {};
|
|
|
|
const int Student::getNumber() const {
|
|
return this->number;
|
|
}
|
|
|
|
const std::string Student::getNumberString() const {
|
|
if (this->isAnyNumber) {
|
|
return "[Any]";
|
|
}
|
|
return std::to_string(this->number);
|
|
}
|
|
|
|
const std::string Student::getName() const {
|
|
if (this->isAnyName) {
|
|
return "[Any]";
|
|
}
|
|
return this->name;
|
|
}
|
|
|
|
void Student::setNumber(const int newNumber) {
|
|
this->isAnyNumber = false;
|
|
this->number = newNumber;
|
|
}
|
|
|
|
void Student::setName(const std::string newName) {
|
|
this->isAnyName = false;
|
|
this->name = newName;
|
|
}
|
|
|
|
void Student::setAnyNumber() {
|
|
this->isAnyNumber = true;
|
|
this->number = 0;
|
|
}
|
|
|
|
void Student::setAnyName() {
|
|
this->isAnyName = true;
|
|
this->name = "";
|
|
}
|
|
|
|
bool Student::matchesNumber(const Student &otherStu) const {
|
|
return this->isAnyNumber || this->number == otherStu.number;
|
|
}
|
|
|
|
bool Student::matchesName(const Student &otherStu) const {
|
|
return this->isAnyName || this->name == otherStu.name;
|
|
}
|
|
|
|
bool Student::matches(const Student &otherStu) const {
|
|
return this->matchesNumber(otherStu) && this->matchesName(otherStu);
|
|
}
|
|
|
|
bool Student::operator==(const Student &otherStu) const {
|
|
return this->matches(otherStu);
|
|
} |