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