-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataMember_Manage.h
283 lines (258 loc) · 8.79 KB
/
DataMember_Manage.h
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#ifndef DATAMEMBER_MANAGE_H
#define DATAMEMBER_MANAGE_H
#include<string.h>
#include<iostream>
#include<conio.h>
#include<windows.h>
#include<stdlib.h>
#include<process.h>
#include<windows.h>
using namespace std;
HWND console = GetConsoleWindow();
RECT rec;
void gotoxy(int x, int y){
COORD c = { x, y };
SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE) , c);
}
void beg(){
GetWindowRect(console, &rec);
int y=44,i;
char yo[]="Nishant And Deepak Presents";
string r="";
string a="";
for(i=26;i>0;i--){
r+=yo[i];
for(int b=r.length();b>=0;b--){
a+=r[b];
}
cout<<a;
Sleep(50);
system("cls");
a="";
}
for(i=0;i<((rec.right-rec.left-(27*8.17))/8.17);i++){
gotoxy(i,0);
cout<<"Nishant And Deepak Presents";
Sleep(50);
system("cls");
GetWindowRect(console, &rec);
}
cout<<"i";
int b=((rec.right-rec.left-(27*8.17))/8.17)-27;
for(i=26;i>=0;i--){
for(int b=0;b<i;b++){
a+=yo[b];
}
gotoxy(i+b,0);
cout<<a;
Sleep(50);
system("cls");
a="";
b+=2;
}
}
char* color(int color=7, char* Message = ""){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
return Message;
}
string middis(string word){
GetWindowRect(console, &rec);
size_t siz=word.length();
size_t mid=((rec.right-rec.left-(siz*8.17))/8.17)/2;
string spaces;
spaces.resize(mid,' ');
word.insert(0,spaces);
return word;
}
class DataMember_Manage
{
private:
static const int no_of_data_members=20;
int alpha,whole,deci,dindex[3][no_of_data_members],dusing_n[3][no_of_data_members];
string data[3][no_of_data_members];
public:
int static constexpr Getno_of_data_members()
{
return no_of_data_members;
}
DataMember_Manage()
{
alpha=0;
whole=0;
deci=0;
for(int y=0;y<3;y++)
{ for(int z=0;z<no_of_data_members;z++)
dusing_n[y][z]=0;
}
for(int y=0;y<3;y++)
{ for(int z=0;z<no_of_data_members;z++)
dindex[y][z]=-2;
}
}
void initializ_zero()
{
alpha=0;
whole=0;
deci=0;
}
void set_using_zero()
{
for(int y=0;y<3;y++)
{
for(int z=0;z<no_of_data_members;z++)
dusing_n[y][z]=0;
}
}
void clear_index()
{
for(int y=0;y<3;y++)
{ for(int z=0;z<no_of_data_members;z++)
dindex[y][z]=-2;
}
}
int dGetusing_n(int data_type,int postion){
return dusing_n[data_type][postion];
}
void dSetusing_n(int data_type,int postion){
dusing_n[data_type][postion] = 1;
}
int Getdindex(int data_type,int postion){
return dindex[data_type][postion];
}
void Setdindex(int val,int data_type,int postion){
dindex[data_type][postion] = val;
}
void tokdata( string data_f){
string temdata[no_of_data_members];
string temp;
int len=(data_f.length()-1);//to be used later for checking in while loop
int u=0,e=0,q=0,pos=0;
if(!(data_f[len]==','))
{
system("cls");
cout<<middis(color(4,"Error"))<<endl;
cout<<color(2,"No Comma at the end")<<endl;
cout<<middis(color(1,"Program will now exit"));
exit(1);
}
while(pos<len)
{
while(1)
{
if(pos>len)
{
system("cls");
cout<<middis(color(4,"Error"))<<endl;
cout<<color(2,"No \'= \'sign in front of data type")<<endl;
cout<<middis(color(1,"Program will now exit"));
exit(1);
}
temp=data_f.substr(pos,data_f.find_first_of(",",pos)-pos);
pos=data_f.find_first_of(",",pos)+1;
u=0,e=0;
while(!u&&!e) //removes space
{ u=temp.compare(temp.length()-1,1," ");
if(!u)
{
size_t found = temp.find_last_of(" ");
temp=temp.substr(0,found);
}
e=temp.compare(0,1," ");
if(!e)
{
size_t found = temp.find_first_of(" ");
temp=temp.substr(found+1);
}
}
if(temp.length()==0){
cout<<"Input Empty"<<endl;
getch();
exit(1);
}
if(!temp.compare(0,1,"="))
break;
if(no_of_data_members==q)
{
cout<<middis(color(4,"Error"));
exit(0);
}
temdata[q]=temp;
q++;
}
string temp2=temp.erase(0,1);
u=0,e=0;
while(!u&&!e) //removes space
{ u=temp2.compare(temp2.length()-1,1," ");
if(!u)
{
size_t found = temp2.find_last_of(" ");
temp2=temp2.substr(0,found);
}
e=temp2.compare(0,1," ");
if(!e)
{
size_t found = temp2.find_first_of(" ");
temp2=temp2.substr(found+1);
}
}
for(int h=0;h<temp2.length();h++)
{
temp2[h]=tolower(temp2[h]);
}
int o=0;
if(!temp2.compare("alphabets"))
{
while (o<q)
{
data[0][alpha+o]=temdata[o];
o++;
}
alpha+=q;
q=0;
}
else if(!temp2.compare("whole number"))
{
while (o<q)
{
data[1][whole+o]=temdata[o];
o++;
}
whole+=q;
q=0;
}
else if(!temp2.compare("decimal"))
{
while (o<q)
{
data[2][deci+o]=temdata[o];
o++;
}
deci+=q;
q=0;
}
else
{
system("cls");
cout<<middis(color(4,"Error in Input"));
exit(1);
}
}
}
int Getalpha()
{
return alpha;
}
int Getwhole()
{
return whole;
}
int Getdeci()
{
return deci;
}
string Getdata(int data_type,int position)
{
return data[data_type][position];
}
};
#endif // DATAMEMBER_MANAGE_H