#include "num.h"

Num::Num(int value, int modulo) : value(value), modulo(modulo) {
}

Num & Num::operator=(const Num &other) {
    this->value = other.value;
    this->modulo = other.modulo;
    return *this;
}

Num Num::operator+(const Num &other) {
    return Num((this->value + other.value) % this->modulo, this->modulo);
}
Num Num::operator-(const Num &other) {
    return Num((this->value - other.value) % this->modulo, this->modulo);
}
Num Num::operator*(const Num &other) {
    return Num((this->value * other.value) % this->modulo, this->modulo);
}
Num Num::operator+(int num) {
    return Num((this->value + num) % this->modulo, this->modulo);
}
Num Num::operator-(int num) {
    return Num((this->value - num) % this->modulo, this->modulo);
}
Num Num::operator*(int num) {
    return Num((this->value * num) % this->modulo, this->modulo);
}

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;
}
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;
}