更改文件夹名。
This commit is contained in:
71
FinalProject/Student.cpp
Normal file
71
FinalProject/Student.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
bool Student::isAnyNumber() const {
|
||||
return this->_isAnyNumber;
|
||||
}
|
||||
|
||||
void Student::setAnyName() {
|
||||
this->_isAnyName = true;
|
||||
this->name = "";
|
||||
}
|
||||
|
||||
bool Student::isAnyName() const {
|
||||
return this->_isAnyName;
|
||||
}
|
||||
|
||||
bool Student::matchesNumber(const Student &otherStu) const {
|
||||
return (this->_isAnyNumber || otherStu._isAnyNumber) ||
|
||||
this->number == otherStu.number;
|
||||
}
|
||||
|
||||
bool Student::matchesName(const Student &otherStu) const {
|
||||
return (this->_isAnyName || otherStu._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);
|
||||
}
|
||||
Reference in New Issue
Block a user