-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror.cpp
More file actions
executable file
·211 lines (196 loc) · 3.71 KB
/
error.cpp
File metadata and controls
executable file
·211 lines (196 loc) · 3.71 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*#ifndef ERROR_H
#define ERROR_H
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>*/
#include "error.h"
#include <curses.h>
using namespace std;
void line(int skip = 1){
cout<<"==========================================";
for(int x = 0; x < skip; x++){
cout<<endl;
}
}
char input(){
system("stty cbreak -echo");
char in = getchar();
system("stty cooked echo");
return in;
}
/*string sinput(){
system("stty cbreak -echo");
string in = getchar();
system("stty cooked echo");
return in;
}*/
int pos_int(){
bool loop;
char ans[10];
int ians;
do{
loop = false;
cin>>ans;
for(int x = 0; x < strlen(ans); x++){
if(!(ans[x] >= '0' && ans[x] <= '9') && loop == false){
cout<<"Incorrect Input!"<<endl<<endl;
cout<<"Try again: ";
loop = true;
}
}
}while(loop == true);
ians = atoi(ans);
return ians;
}
int pos_int(char *ans){
bool loop;
int ians;
do{
loop = false;
for(int x = 0; x < strlen(ans); x++){
if(!(ans[x] >= '0' && ans[x] <= '9') && loop == false){
cout<<"Incorrect Input!"<<endl<<endl;
cout<<"Try again: ";
cin>>ans;
loop = true;
}
}
}while(loop == true);
ians = atoi(ans);
return ians;
}
signed int signed_int(){
bool loop;
char ans[10];
signed int ians;
do{
loop = false;
cin>>ans;
for(int x = 0; x < strlen(ans); x++){
if(ans[0] == '-'){
}else if(!(ans[x] >= '0' && ans[x] <= '9') && loop == false){
cout<<"Incorrect Input!"<<endl<<endl;
cout<<"Try again: ";
loop = true;
}
}
}while(loop == true);
ians = atoi(ans);
return ians;
}
int pos_float(){
bool loop;
char ans[10];
float fans;
do{
bool dec = false;
loop = false;
cin>>ans;
for(int x = 0; x < strlen(ans); x++){
if(!(ans[x] >= '0' && ans[x] <= '9') || (ans[x] == '.' && dec == false) && loop == false){
cout<<"Incorrect Input!"<<endl<<endl;
cout<<"Try again: ";
loop = true;
}if(ans[x] == '.'){
dec = true;
}
}
}while(loop == true);
fans = atof(ans);
return fans;
}
/*signed int signed_float(){
bool loop;
char ans[10];
signed float fans;
do{
bool dec = false;
loop = false;
cin>>ans;
for(int x = 0; x < strlen(ans); x++){
if(ans[0] == '-'){
}else if(!(ans[x] >= '0' && ans[x] <= '9') || (ans[x] == '.' && dec == false) && loop == false){
cout<<"Incorrect Input!"<<endl<<endl;
cout<<"Try again: ";
loop = true;
}if(ans[x] == '.'){
dec = true;
}
}
}while(loop == true);
fans = atof(ans);
return fans;
}*/
int answer(int x){
bool loop = false;
while(loop == false){
int ans = pos_int();
if(ans > x || ans <= 0){
cout<<"Incorect Input"<<endl<<endl;
cout<<"Try again: ";
loop = false;
}else{
cout<<endl;
return ans;
}
}
}
int answer(int x, char *ans){
bool loop = false;
while(loop == false){
int ians = pos_int(ans);
if(ians > x || ians <= 0){
cout<<"Incorect Input"<<endl<<endl;
cout<<"Try again: ";
loop = false;
}else{
cout<<endl;
return ians;
}
}
}
float answer(float x){
bool loop = false;
while(loop == false){
float ans = pos_float();
if(ans > x || ans <= 0){
cout<<"Incorect Input"<<endl<<endl;
cout<<"Try again: ";
loop = false;
}else{
cout<<endl;
return ans;
}
}
}
string str_answer(string *options, int size, bool wait){
bool loop = false;
string ans;
while(loop == false){
if(wait == true){
cin>>ans;
}else{
char temp = input();
ans = temp;
cout<<endl;
}
for(int x = 0; x < size; x++){
if(options[x] == ans){
loop = true;
}
if(loop == true){
x = 100;
}
}
if(loop == false){
cout<<"Incorect Input"<<endl<<endl;
cout<<"Try again: ";
}else{
string clean_ans;
clean_ans = ans;
return clean_ans;
}
}
}
//#endif