-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircularInt.hpp
More file actions
179 lines (146 loc) · 8.23 KB
/
CircularInt.hpp
File metadata and controls
179 lines (146 loc) · 8.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/**
*hidden file of class CircularInt
*Authors Alexey Titov and Shir Bentabou
*Version 2.0
**/
#pragma once
//libraries
#include <iostream>
using namespace std;
//our class
class CircularInt{
private:
int min; //always set to 1 - constructor wise too
int max; //always set to 12 - constructor wise too
int pos; //its current position
// std::exception runtime_error;
public:
//constructor with minimal and maximal values
CircularInt(int MIN,int MAX){
if (MIN>MAX){
cout << "MIN larger than MAX!" << endl;
exit(1);
}
min=MIN;
max=MAX;
pos=MIN;
}
//set for our exception
// SetValueException(string mess){
// runtime_error(mess);
// }
//plus function - a general function that will help us with all addition operators
int plus(int min, int max, int pos, int x);
//minus function - a general function that will help us with all subtraction operators
int minus(int min, int max, int pos, int x);
//multiply function - a general function that will help us with all multiplying operators
int multiply(int min, int max, int pos, int by_x);
//division function - a general function that will help us with all dividing operators
int divide(int min, int max, int pos, int by_x);
//modulo function - a general function that will help us with all modulo operators
int modulo(int min, int max, int pos, int mod);
//Overloading for '+=' operator for hour type!
CircularInt& operator+=(const int& other);
//Overloading for '-=' operator for hour type!
CircularInt& operator-=(const int& other);
//Overloading for '*=' operator for hour type!
CircularInt& operator*=(const int& mult);
//Overloading for '/=' operator for hour type!
CircularInt& operator/=(const int& div);
//Overloading for '%=' operator for hour type!
CircularInt& operator%=(const int& mod);
//Overloading for 'var++' operator for hour type!
int operator++(int);
//Overloading for '++var' operator for hour type!
CircularInt& operator++();
//Overloading for 'var--' operator for hour type!
int operator--(int);
//Overloading for '--var' operator for hour type!
CircularInt& operator--();
//Overloading - operator for complementary action
int operator-();
//Overloading for '=' operator for hour type!
CircularInt& operator =(const CircularInt& other);
//Overloading '=' operator between hour object and int.
CircularInt& operator =(const int& other);
//----------------------------------
// friend global IO operators
//----------------------------------
friend ostream& operator<< (ostream& os, const CircularInt& c);
friend istream& operator>> (istream& is,CircularInt& c);
//-------------------------------------
// friend global binary operators
//-------------------------------------
friend const CircularInt operator - (const int a,const CircularInt& other);
friend const CircularInt operator + (const int a,const CircularInt& other);
friend const CircularInt operator - (const CircularInt& other,const int a);
friend const CircularInt operator + (const CircularInt& other,const int a);
friend const CircularInt operator + (const CircularInt& a, const CircularInt& b);
friend const CircularInt operator - (const CircularInt& a, const CircularInt& b);
friend const CircularInt operator * (const CircularInt& a, const CircularInt& b);
friend const CircularInt operator * (const int& a, const CircularInt& b);
friend const CircularInt operator * (const CircularInt& b, const int& a);
friend const CircularInt operator / (const CircularInt& a, const CircularInt& b);
friend const CircularInt operator / (const int& div, const CircularInt& b);
friend const CircularInt operator / (const CircularInt& a,const int& div);
friend const CircularInt operator % (const CircularInt& a, const int& mod);
friend bool operator == (const CircularInt& a, const CircularInt& b);
friend bool operator != (const CircularInt& a, const CircularInt& b);
friend bool operator > (const CircularInt& a, const CircularInt& b);
friend bool operator < (const CircularInt& a, const CircularInt& b);
friend bool operator >= (const CircularInt& a, const CircularInt& b);
friend bool operator <= (const CircularInt& a, const CircularInt& b);
friend const CircularInt operator%(const CircularInt& a, const int& mod);
friend const CircularInt operator%(const int& mod, const CircularInt& a);
friend const CircularInt operator%(const CircularInt& a, const CircularInt& b);
};
//----------------------------------------
// friend global IO operators
//----------------------------------------
ostream& operator<< (ostream& os, const CircularInt& c);
istream& operator>> (istream& is,CircularInt& c);
//-------------------------------------
// friend global binary operators
//-------------------------------------
//Overloading for '-' operator for hour type! (int and CircularInt)
const CircularInt operator - (const int a,const CircularInt& other);
//Overloading for '-' operator for hour type! (CircularInt and int)
const CircularInt operator - (const CircularInt& other,const int a);
//Overloading for '+' operator for hour type! (int and CircularInt)
const CircularInt operator+(const int a,const CircularInt& other);
//Overloading for '+' operator for hour type! (CircularInt and int)
const CircularInt operator+(const CircularInt& other,const int a);
//Overloading for '+' operator for hour type! (CircularInt and CircularInt)
const CircularInt operator + (const CircularInt& a, const CircularInt& b);
//Overloading for '-' operator for hour type! (CircularInt and CircularInt)
const CircularInt operator - (const CircularInt& a, const CircularInt& b);
//Overloading for '*' operator for hour type! (CircularInt and CircularInt)
const CircularInt operator*(const CircularInt& a, const CircularInt& b);
//Overloading for '*' operator for hour type! (int and CircularInt)
const CircularInt operator*(const int& a, const CircularInt& b);
//Overloading for '*' operator for hour type! (CircularInt and int)
const CircularInt operator*(const CircularInt& b, const int& a);
//Overloading for '/' operator for hour type! (CircularInt and CircularInt)
const CircularInt operator/(const CircularInt& a, const CircularInt& b);
//Overloading for '/' operator for hour type! (int and CircularInt)
const CircularInt operator/(const int& div, const CircularInt& b);
//Overloading for '/' operator for hour type! (CircularInt and int)
const CircularInt operator / (const CircularInt& a,const int& div);
//Overloading for '==' operator for hour type! (Two CircularInt types)
bool operator == (const CircularInt& a, const CircularInt& b);
//Overloading for '!=' operator for hour type! (Two CircularInt types)
bool operator != (const CircularInt& a, const CircularInt& b);
//Overloading for '>' operator for hour type! (Two CircularInt types)
bool operator > (const CircularInt& a, const CircularInt& b);
//Overloading for '<' operator for hour type! (Two CircularInt types)
bool operator < (const CircularInt& a, const CircularInt& b);
//Overloading for '>=' operator for hour type! (Two CircularInt types)
bool operator >= (const CircularInt& a, const CircularInt& b);
//Overloading for '<=' operator for hour type! (Two CircularInt types)
bool operator <= (const CircularInt& a, const CircularInt& b);
//Overloading for '%' operator for hour type!
const CircularInt operator%(const CircularInt& a, const int& mod);
//Overloading for '%' operator for hour type! (int and CircularInt)
const CircularInt operator%(const int& mod, const CircularInt& a);
//Overloading for '%' operator for hour type! (Two CircularInts)
const CircularInt operator%(const CircularInt& a, const CircularInt& b);