#include "num.h" #include Num::Num(int value, int modulo) { (modulo != 0) ? this->value = value % modulo : this->value = value; this->modulo = modulo; } Num &Num::operator=(const Num &other) = default; Num Num::operator+(const Num &other) { Num TMP((this->value + other.value) % this->modulo, this->modulo); return TMP; } Num Num::operator*(const Num &other) { Num TMP((this->value * other.value) % this->modulo, this->modulo); return TMP; } Num Num::operator-(const Num &other) { Num TMP((this->value - other.value) % this->modulo, this->modulo); return TMP; } Num Num::operator+(int number) { Num TMP((this->value + number) % this->modulo, this->modulo); return TMP; } Num Num::operator-(int number) { Num TMP((this->value - number) % this->modulo, this->modulo); return TMP; } Num Num::operator*(int number) { Num TMP((this->value * number) % this->modulo, this->modulo); return TMP; } Num &Num::operator+=(int num) { this->value = (this->value + num) % this->modulo; return *this; } Num &Num::operator*=(int num) { this->value = (this->value * num) % this->modulo; return *this; } Num &Num::operator-=(int num) { this->value = (this->value - num) % this->modulo; return *this; } Num &Num::operator*=(const Num &other) { this->value = (this->value * other.value) % this->modulo; return *this; } Num &Num::operator-=(const Num &other) { this->value = (this->value - other.value) % this->modulo; return *this; } Num &Num::operator+=(const Num &other) { this->value = (this->value + other.value) % this->modulo; return *this; }