#include "num.h"
#include <iostream>


Num::Num(int value, int modulo) {
  (modulo == 0) ? this->value = value : this->value = value % modulo;
  this->modulo = modulo;
}
Num &Num::operator=(const Num &other) = default;
Num Num::operator+(int number) {
  this->value += number;
  this->value %= this->modulo;
  return *this;
}
Num Num::operator-(int number) {
  this->value -= number;
  this->value %= this->modulo;
  return *this;
}
Num Num::operator*(int number) {
  this->value *= number;
  this->value %= this->modulo;
  return *this;
}
Num &Num::operator+=(int number) {
  this->value += number;
  this->value %= this->modulo;
  return *this;
}

Num &Num::operator-=(int number) {
  this->value -= number;
  this->value %= this->modulo;
  return *this;
}
Num &Num::operator*=(int number) {
  this->value *= number;
  this->value %= this->modulo;
  return *this;
}

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

Num &Num::operator-=(const Num &other) {
  this->value += other.value;
  this->modulo = modulo;
  this->value %= this->modulo;
  return *this;
}
Num &Num::operator*=(const Num &other) {
  this->value += other.value;
  this->modulo = modulo;
  this->value %= this->modulo;
  return *this;
}
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;
}