-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSource1.cpp
More file actions
559 lines (297 loc) · 8.62 KB
/
Source1.cpp
File metadata and controls
559 lines (297 loc) · 8.62 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
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
#pragma
#include "Header.h"
void spreadsheet::upscale()
{
int c;
std::cout << " how many would you like to add " << std::endl;
std::cin >> c;
std :: cout << std::endl;
temp = new int[c + amount];
for (int d = 0; d < amount; d++)
{
*(temp + d) = *(fir + d);
}
delete[] fir;
fir = new int[c + amount];
for (int d = 0; d < amount; d++)
{
*(fir + d) = *(temp + d);
}
for (int d = amount; d < (amount + c); d++)
{
*(fir + d) = d;
}
amount = amount + c;
/*for (int d = 0; d < amount; d++)
{
std::cout << d << " this is the array and the value is " << *(fir + d) << std::endl;
}*/
std::cout << " \n \n \n " << std::endl;
delete[]temp;
temp = nullptr;
}
void spreadsheet::vals()
{
for (int x = 0; x < amount; x++)
{
std::cout << "this is element number is " << x << " the value is " << *(fir + x) <<std::endl;
}
std::cout << " ------------------------------------------------------------------ \n" << std::endl;
}
spreadsheet::spreadsheet() {
std::cout << "the array is defaulted to 10 " << std::endl;// original used user input but i want the user to resize when neccesary
amount = 10;
fir = new int[amount];
for (int d = 0; d < amount; d++)
{
*(fir + d) = d;
}
for (int d = 0; d < amount; d++)
{
std::cout << d << " this is the array and the value is " << *(fir + d) << std::endl;
}
std::cout << "end of constructor \n \n" << std::endl;
}
void spreadsheet::deleted() {
delete[] fir;
fir = nullptr;
}
void spreadsheet::delear() {
int con = 1;
while (con == 1)
{
int choose;
int yesorno = 1;
std::cout << " What array element would you like to delete. " << std::endl;
vals();
std::cout << "please enter your choice " << std::endl;
std::cin >> choose;
std::cout << " The element you have chosen is \n " << choose << " " << *(fir + choose)<< "if this is correct press 1 for yes or 0 for no" << std::endl;
std::cin >> yesorno;
if (yesorno == 1)
{
if (choose == (amount-1))
{
temp = new int[amount - 1];
for (int x = 0; x < (amount - 1); x++)
{
*(temp + x) = *(fir + x);
std::cout << *(temp + x) << std::endl;
}
delete[] fir;
fir = nullptr;
amount = --amount;
fir = new int[amount];
for (int x = 0; x < amount; x++)
{
*(fir + x) = *(temp + x);
std::cout << " value should be transfer " << *(fir + x) <<std::endl;
}
delete[] temp;
temp = nullptr;
}
else if (choose < 0 || choose >= amount )
{
std::cout << "ill show you to putting a incorrect value in " << std::endl;
std::cout << " now deleting system 32 GGWP joke on you " << std::endl;
}
else if (choose < (amount - 1))
{
temp = new int[amount - 1];
for (int x = choose; x < (amount - 1); x++)
{
*(fir + x) = *(fir + (x+1));
std::cout << " value copied " << *(fir + (x)) << std::endl;
}
for (int x = 0; x < (amount -1); x++)
{
*(temp + x) = *(fir + x);
std::cout << " value copied " << *(temp + x) << std::endl;
}
delete[] fir;
fir = nullptr;
amount = amount - 1;
fir = new int[amount];
for (int x = 0; x < amount; x++)
{
*(fir + x) = *(temp + x);
std::cout << "the value of " << x << " is " << *(fir + x) <<std::endl;
}
delete[] temp;
temp = nullptr;
}
con = 0;
}
else {
con = 1;
}
}
}
void spreadsheet::change()
{
int a;
vals();
std::cout << "what value would you like to edit " << std::endl;
std::cin >> a;
if (a <0)
{
std::cout << " error retry with a number that greater than or equal than 0 " << std::endl;
}
else if (a < amount)
{
int b;
std::cout << " Type the integer value you want to change that element " << a << std::endl;
std::cin >> b;
*(fir + a) = b;
std::cout << "\n element " << a << "is now " << *(fir + a) << std::endl;
}
else {
std::cout << " the value you enter is too high please type a value within the parameters " <<std::endl;
}
}
void accessspec(spreadsheet* name, int b)// access the class array within a specfic
{
std::cout << " there are " << b << " sheet/classarrays " << std::endl;
std::cout << " please enter your array index you would like to access --> " << std::endl;
int c;
std::cin >> c;
if (c >= 0 && c < b)
{
name[c].vals();
}
else {
std::cout << "incorrect value try again " << std::endl;
}
}
void chgval(spreadsheet* name, int b)
{
std::cout << " there are " << b << " sheet/classarrays " << std::endl;
int a;
std::cout << " which element within the class array(cell) would you like to change " << std::endl;
std::cin >> a;
if (a >= 0 && a < b) {
name[a].change();
name[a].vals();
}
else {
std::cout << " error bitch " << std::endl;
}
std::cout << " done changing value " << std::endl;
}
void chginarr(spreadsheet* name, int b)// access internal array and resizes it
{
std::cout << " there are " << b << "sheet/classarrays " << std::endl;
int a;
std::cout << " which array within the class would you like to resize " << std::endl;
std::cin >> a;
if (a >= 0 && a < b)
{
int c;
std::cout << " would you like to upscale or down scale, 1 for upscale , 2 for downscale --> " << std::endl;
std::cin >> c;
if (c == 1)
{
std::cout << "you have choosen to add a new array " << std::endl;
name[a].upscale();
}
else if (c == 2)
{
std::cout << " you have choosen deletion " << std::endl;
name[a].delear();
}
else {
std::cout << "error baby ,user to be specific " << std::endl;// dont you just get bored of the same thing over and over
}
}
else {
std::cout << "invalid value please try again " << std::endl;
}
}
void chkclass(spreadsheet* name, int b)
{
for (int c = 0; c < b; c++)
{
std::cout << "class array" << c << " cells wihin class " << std::endl;
name[c].vals();
std::cout << "all the values" << std::endl;
}
}
spreadsheet* resizecal(spreadsheet* name, int& b) // dont forget to return the pointer
{
int a;
std::cout << " what would you like to resize your class to " << std::endl;
std::cin >> a;
if (a > b)
{
spreadsheet* temp;
temp = new spreadsheet[a];
for (int c = 0; c < b; c++)
{
temp[c] = name[c];
}
delete name; // this release the memory connected to name
name = new spreadsheet[a];
for (int c = 0; c < b; c++)
{
name[c] = temp[c];
}
std::cout << "second phase complete " << std::endl;
b = a;
//std::cout << b << "is equal to a \n";
delete temp;
temp = nullptr;
return name;
}
else {
std::cout << "try again ";
return name;
}
}
void running()
{
int con = 1;
spreadsheet* iroh;
int count = 1;
iroh = new spreadsheet[count];
while (con == 1)
{
int b;
std::cout << "[0] if you want to terminate the program\n" << std::endl;
std::cout << " [1] what would you like to do 1 check all the variable within all the sheets type 1 \n" << std::endl;
std::cout << "[2] if you would like to increase class array or the sheets type 2 \n " << std::endl;
std::cout << "[3] would you like to view the array within the the class array (sheet) type 3\n" << std::endl;
std::cout << "[4] if you would like to resize a specific class array cell type 4\n" << std::endl;
std::cout << "[5]if you would like to change a specific value within a cell type 5\n " << std::endl;
std::cin >> b;
if (b == 1)
{
chkclass(iroh, count);
}
else if (b == 2)
{
iroh = resizecal(iroh, count); // must return the pointer
}
else if (b == 3)
{
accessspec(iroh, count);
}
else if (b == 4)
{
chginarr(iroh, count);
}
else if (b == 5)
{
chgval(iroh, count);
}
else if (b == 0)
{
con = 0;
}
else {
std::cout << "error " << std::endl;
}
std::cout << "\n \n \n \n" << std::endl;
}
delete[] iroh;
iroh = nullptr;
}