-
Notifications
You must be signed in to change notification settings - Fork 0
/
Location.cpp
2797 lines (2327 loc) · 141 KB
/
Location.cpp
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
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <typeinfo>
#include <string>
#include <cstring>
#include <fstream>
#include <sstream>
#include <vector>
#include <map>
#include <cctype>
#include <stdexcept>
#include <thread>
#include <chrono>
#include "Location.h"
#include "Customer.h"
#include "Design.h"
#include "Employee.h"
#include "Finances.h"
#include "HumanResources.h"
#include "Investor.h"
#include "Manager.h"
#include "Manufacturing.h"
#include "Marketing.h"
#include "Person.h"
#include "ResearchDev.h"
#include "Sales.h"
#include "Software.h"
#include "Supplier.h"
#include "VIP.h"
//Initialisation
Location::Location() {
address = "none";
people = new Person*[0]; //Creats an array with 0 size as people will be added with a function
curr_size = 0;
};
Location::Location(std::string address) {
this->address = address;
people = new Person*[0];
curr_size = 0;
};
// add person code using the person
bool Location::addPerson(Person* new_person) {
Person** new_people = new Person*[curr_size + 1]; // Creates a new array of size one larger than the old one
for (int i = 0; i < curr_size; i++) {new_people[i] = people[i];} // Copies the old array to the new array
new_people[curr_size] = new_person; // Creates the new person at the end of the array
curr_size++; // Increments curr_size for next time
delete[] people; // Deletes the old array so there isnt a memory leak
people = new_people; // Makes the old pointer now point to the new array
return true;
}
// remove person code using the name of the person (can be easily changed to other traits)
bool Location::rmPerson(const std::string& name) {
int index = -1; // Sets index at -1 to setup for the no found clause
for (int i = 0; i < curr_size; i ++){ // Searches all the people for a matching name
if (people[i]->get_name() == name){
index = i;
break;
}
}
if (index == -1) {return false;} // Clause for if no name found
for (int i = index; i < curr_size - 1; i++){ // Shifts the array so that there are no holes where the removed employee is
people[i] = people[i + 1];
}
curr_size--; // Updates the size
// Code to remove the extra size of the dynamic array
Person** new_people = new Person*[curr_size]; // Creates a new array of correct size
for (int i = 0; i < curr_size; i++){ // Copies the old array to the new array
new_people[i] = people[i];
}
delete[] people; // Deletes the old array so there isnt a memory leak
people = new_people; // Makes the old pointer now point to the new array
return true;
}
// Getters
std::string Location::get_address() {return address;};
int Location::get_curr_size() {return curr_size;};
//Setters
void Location::set_address(std::string address) {this->address = address;};
//Deconstructor
Location::~Location() {delete[] people;}
//Functions
// Password checking function
bool Location::Access(std::string username, std::string password){
int index = -1; // Sets index at -1 to setup for the no found clause
for (int i = 0; i < curr_size; i ++){ // Searches all the names in location to find the index
if (people[i]->get_name() == username){
index = i;
break;
}
}
if (username == "admin" && password == "admin"){
return true;
}
if (index == -1){ // Clause for if no name found
std::cout << "Username incorrect." << std::endl;
return false;
}
if (people[index]->get_password() == password){ // Checking if the password matches
if (strcmp(typeid(*people[index]).name(), "7Manager") == 0){ // In GCC compiling this works as typeid will show 7 representing the characters in the class then the class name
//std::cout << "Access granted." << std::endl;
return true;
}
}
//std::cout << "Username or password is incorrect. " << std::endl; // If no other check it hit then the username must not match the password
return false;
}
//Since we only have c++11 we need to create the fileexists function
bool Location::fileExists(const std::string& filename) {
std::ifstream file(filename);
return file.good();
}
//Splits the string into 3 parts to setup for file reading
std::vector<std::string> Location::splitString(const std::string& input) {
std::vector<std::string> parts;
std::istringstream iss(input);
std::string part;
// Extract the first part
if (std::getline(iss, part, ' ')) {
parts.push_back(part);
} else {
parts.push_back("");
}
// Extract the second part
if (std::getline(iss, part, ' ')) {
parts.push_back(part);
} else {
parts.push_back("");
}
// Extract the rest of the input as the third part
if (std::getline(iss, part)) {
parts.push_back(part);
} else {
parts.push_back("");
}
return parts;
}
//Converts a string to an integer and handles invalid inputs
int Location::toInt(std::string input) {
bool valid = true;
for (char c : input) {
if (!isdigit(c)) {
valid = false;
break;
}
}
if (valid) {return std::stoi(input);} else {return 0;}
}
//Converts a string to a float and handles invalid inputs
float Location::toFloat(const std::string& input) {
bool valid = true;
bool decimalPointFound = false;
for (char c : input) {
if (c == '.') {
if (decimalPointFound) {
valid = false;
break;
}
decimalPointFound = true;
} else if (!std::isdigit(c)) {
valid = false;
break;
}
}
if (valid && !input.empty() && input != ".") {
try {
return std::stof(input); // Convert valid string to float
} catch (const std::invalid_argument& e) {
return 0.0f; // In case of invalid argument exception
} catch (const std::out_of_range& e) {
return 0.0f; // In case of out of range exception
}
} else {
return 0.0f; // Return 0.0 for invalid input
}
}
//This function will interprate a string and use it
void Location::runCommand(std::string command) {
std::vector<std::string> parts = splitString(command);
if (command == "save"){
std::string fileName;
std::cout << "Enter the name of your save file (make sure to include .txt): ";
std::cin >> fileName;
Save(fileName);
} else if (command == "help"){
std::cout << "\nThere are 6 types of commands; get, set, rm, add, e and save.\n\n";
std::cout << "save - save your progress so you can load it later.\n\n";
std::cout << "get info: name - is the main command to get all the information based on the input name.\n";
std::cout << "get names - is the command to list all of the avaliable names.\n\n";
std::cout << "set: variable: name - is the base command for setting data for a variable based on someone's name.\n";
std::cout << "variable: name, age, phonenumber, address, id, hourlysalary, weeklyhours, attendance, datejoined, performance,\n"
"position, banknumber, bank, spendings, purchasehistory, notes, finisheddesigns, currentdesigns, turnover, profit,\n"
"budget, expense, trained, hired, fired, retired, investment, password, certification, carscomplete, success,\n"
"finishedresearch, currentresearch, expertise, conversion, sold, revenue, languages, finishedprojects, currentprojects,\n"
"cargoamount, annualcost, cargo, referrals\n\n";
std::cout << "rm: name - is the command used to remove a person based on their name.\n\n";
std::cout << "add: class: name - is the command to add a class with a new person name.\n";
std::cout << "class: Customer, Design, Finances, HumanResources, Investor, Manager, Manufacturing, ResearchDev, Sales,\n"
"Software, Supplier, VIP\n\n";
std::cout << "save - is the function to save your data into a file which can be loaded back in.\n\n";
std::cout << "e - is the function to exit, note you should save before exiting.\n\n";
} else if (parts[0] == "get"){
if (parts[1] == "names"){
std::cout << "Names: \n\n";
for (int i = 0; i < curr_size; i++){
std::cout << people[i]->get_name() << " - " << typeid(*people[i]).name() << std::endl;
}
}
if (parts[1] == "info"){
std::string role;
int index;
for (int i = 0; i < curr_size; i++){
if (people[i]->get_name() == parts[2]){
index = i;
role = typeid(*people[i]).name();
}
}
if (role == "8Customer") { /////////////////////////////////////////////////////////////
std::cout << "Customer " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "Bank number: " << people[index]->get_bankAccount() << std::endl;
std::cout << "Bank: " << people[index]->get_bank() << std::endl;
std::cout << "Client ID: " << people[index]->get_clientId() << std::endl;
std::cout << "Spendings: " << people[index]->get_spendings() << std::endl;
std::cout << "Purchas History: " << people[index]->get_purchase_history() << std::endl;
std::cout << "Notes: " << people[index]->get_notes() << std::endl;
} else if (role == "6Design") {/////////////////////////////////////////////////////////////
std::cout << "Designer " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "ID: " << people[index]->get_ID() << std::endl;
std::cout << "Hourly Salary: " << people[index]->get_salary_hourly() << std::endl;
std::cout << "Weekly Hours: " << people[index]->get_hours_weekly() << std::endl;
for (int j = 0; j < 7; j++){
if (people[index]->get_attendance(j)){
std::cout << "Day " << j + 1 << " : True\n";
} else {std::cout << "Day " << j + 1 << " : False\n";}
}
std::cout << "Date Joined: " << people[index]->get_date_joined() << std::endl;
std::cout << "Performance out of 10: " << people[index]->get_performance() << std::endl;
std::cout << "Position: " << people[index]->get_position() << std::endl;
std::cout << "Finished Designs: " << people[index]->get_finished() << std::endl;
std::cout << "Current Designs: " << people[index]->get_design_current() << std::endl;
} else if (role == "8Finances"){/////////////////////////////////////////////////////////////
std::cout << "Finances " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "ID: " << people[index]->get_ID() << std::endl;
std::cout << "Hourly Salary: " << people[index]->get_salary_hourly() << std::endl;
std::cout << "Weekly Hours: " << people[index]->get_hours_weekly() << std::endl;
for (int j = 0; j < 7; j++){
if (people[index]->get_attendance(j)){
std::cout << "Day " << j + 1 << " : True\n";
} else {std::cout << "Day " << j + 1 << " : False\n";}
}
std::cout << "Date Joined: " << people[index]->get_date_joined() << std::endl;
std::cout << "Performance out of 10: " << people[index]->get_performance() << std::endl;
std::cout << "Position: " << people[index]->get_position() << std::endl;
std::cout << "Turnover: " << people[index]->get_turnover() << std::endl;
std::cout << "Profit: " << people[index]->get_profit() << std::endl;
std::cout << "Budget: " << people[index]->get_budget() << std::endl;
std::cout << "Expense: " << people[index]->get_expense() << std::endl;
} else if (role == "14HumanResources"){/////////////////////////////////////////////////////////////
std::cout << "HumanResources " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "ID: " << people[index]->get_ID() << std::endl;
std::cout << "Hourly Salary: " << people[index]->get_salary_hourly() << std::endl;
std::cout << "Weekly Hours: " << people[index]->get_hours_weekly() << std::endl;
for (int j = 0; j < 7; j++){
if (people[index]->get_attendance(j)){
std::cout << "Day " << j + 1 << " : True\n";
} else {std::cout << "Day " << j + 1 << " : False\n";}
}
std::cout << "Date Joined: " << people[index]->get_date_joined() << std::endl;
std::cout << "Performance out of 10: " << people[index]->get_performance() << std::endl;
std::cout << "Position: " << people[index]->get_position() << std::endl;
std::cout << "Amount of trained people: " << people[index]->get_trained() << std::endl;
std::cout << "Amount of hired: " << people[index]->get_hired() << std::endl;
std::cout << "Amount of fired: " << people[index]->get_fired() << std::endl;
std::cout << "Amount of retired: " << people[index]->get_retired() << std::endl;
} else if (role == "8Investor"){/////////////////////////////////////////////////////////////
std::cout << "Investor " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "amount of investment: " << people[index]->get_amount_of_investment() << std::endl;
} else if (role == "7Manager"){/////////////////////////////////////////////////////////////
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "Hourly Salary: " << people[index]->get_salary_hourly() << std::endl;
std::cout << "Weekly Hours: " << people[index]->get_hours_weekly() << std::endl;
std::cout << "ID: " << people[index]->get_ID() << std::endl;
for (int j = 0; j < 7; j++){
if (people[index]->get_attendance(j)){
std::cout << "Day " << j + 1 << " : True\n";
} else {std::cout << "Day " << j + 1 << " : False\n";}
}
std::cout << "Date Joined: " << people[index]->get_date_joined() << std::endl;
std::cout << "Performance out of 10: " << people[index]->get_performance() << std::endl;
std::cout << "Position: " << people[index]->get_position() << std::endl;
std::cout << "Password: " << people[index]->get_password() << std::endl;
} else if (role == "13Manufacturing"){/////////////////////////////////////////////////////////////
std::cout << "Manufacturing " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "ID: " << people[index]->get_ID() << std::endl;
std::cout << "Hourly Salary: " << people[index]->get_salary_hourly() << std::endl;
std::cout << "Weekly Hours: " << people[index]->get_hours_weekly() << std::endl;
for (int j = 0; j < 7; j++){
if (people[index]->get_attendance(j)){
std::cout << "Day " << j + 1 << " : True\n";
} else {std::cout << "Day " << j + 1 << " : False\n";}
}
std::cout << "Date Joined: " << people[index]->get_date_joined() << std::endl;
std::cout << "Performance out of 10: " << people[index]->get_performance() << std::endl;
std::cout << "Position: " << people[index]->get_position() << std::endl;
std::cout << "Certification : " << people[index]->get_certification() << std::endl;
std::cout << "Cars_complete : " << people[index]->get_cars_complete() << std::endl;
} else if (role == "9Marketing"){/////////////////////////////////////////////////////////////
std::cout << "Marketing " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "ID: " << people[index]->get_ID() << std::endl;
std::cout << "Hourly Salary: " << people[index]->get_salary_hourly() << std::endl;
std::cout << "Weekly Hours: " << people[index]->get_hours_weekly() << std::endl;
for (int j = 0; j < 7; j++){
if (people[index]->get_attendance(j)){
std::cout << "Day " << j + 1 << " : True\n";
} else {std::cout << "Day " << j + 1 << " : False\n";}
}
std::cout << "Date Joined: " << people[index]->get_date_joined() << std::endl;
std::cout << "Performance out of 10: " << people[index]->get_performance() << std::endl;
std::cout << "Position: " << people[index]->get_position() << std::endl;
std::cout << "Success rate: " << people[index]->get_success_rate() << std::endl;
} else if (role == "11ResearchDev"){/////////////////////////////////////////////////////////////
std::cout << "ResearchDev " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "ID: " << people[index]->get_ID() << std::endl;
std::cout << "Hourly Salary: " << people[index]->get_salary_hourly() << std::endl;
std::cout << "Weekly Hours: " << people[index]->get_hours_weekly() << std::endl;
for (int j = 0; j < 7; j++){
if (people[index]->get_attendance(j)){
std::cout << "Day " << j + 1 << " : True\n";
} else {std::cout << "Day " << j + 1 << " : False\n";}
}
std::cout << "Date Joined: " << people[index]->get_date_joined() << std::endl;
std::cout << "Performance out of 10: " << people[index]->get_performance() << std::endl;
std::cout << "Position: " << people[index]->get_position() << std::endl;
std::cout << "Finished researches: " << people[index]->get_finished() << std::endl;
std::cout << "Current research: " << people[index]->get_research() << std::endl;
std::cout << "Expertise: " << people[index]->get_expertise() << std::endl;
} else if (role == "5Sales"){/////////////////////////////////////////////////////////////
std::cout << "Sales " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "ID: " << people[index]->get_ID() << std::endl;
std::cout << "Hourly Salary: " << people[index]->get_salary_hourly() << std::endl;
std::cout << "Weekly Hours: " << people[index]->get_hours_weekly() << std::endl;
for (int j = 0; j < 7; j++){
if (people[index]->get_attendance(j)){
std::cout << "Day " << j + 1 << " : True\n";
} else {std::cout << "Day " << j + 1 << " : False\n";}
}
std::cout << "Date Joined: " << people[index]->get_date_joined() << std::endl;
std::cout << "Performance out of 10: " << people[index]->get_performance() << std::endl;
std::cout << "Position: " << people[index]->get_position() << std::endl;
std::cout << "Conversion rate: " << people[index]->get_conversion_rate() << std::endl;
std::cout << "Sold cars: " << people[index]->get_cars_complete() << std::endl;
std::cout << "Revenue: " << people[index]->get_revenue() << std::endl;
} else if (role == "8Software"){////////////////////////////////////////////////////////////
std::cout << "Software " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "ID: " << people[index]->get_ID() << std::endl;
std::cout << "Hourly Salary: " << people[index]->get_salary_hourly() << std::endl;
std::cout << "Weekly Hours: " << people[index]->get_hours_weekly() << std::endl;
for (int j = 0; j < 7; j++){
if (people[index]->get_attendance(j)){
std::cout << "Day " << j + 1 << " : True\n";
} else {std::cout << "Day " << j + 1 << " : False\n";}
}
std::cout << "Date Joined: " << people[index]->get_date_joined() << std::endl;
std::cout << "Performance out of 10: " << people[index]->get_performance() << std::endl;
std::cout << "Position: " << people[index]->get_position() << std::endl;
std::cout << "Languages: " << people[index]->get_languages() << std::endl;
std::cout << "current projects: " << people[index]->get_projects_current() << std::endl;
std::cout << "Finished projects: " << people[index]->get_finished() << std::endl;
} else if (role == "8Supplier"){/////////////////////////////////////////////////////////////
std::cout << "Supplier " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "Amount of cargo: " << people[index]->get_amount_of_cargo() << std::endl;
std::cout << "Annually cost: " << people[index]->get_cost_annually() << std::endl;
std::cout << "Cargo: " << people[index]->get_cargo() << std::endl;
} else if (role == "3VIP"){/////////////////////////////////////////////////////////////
std::cout << "VIP " << parts[2] << " has information: \n\n";
std::cout << "Age: " << people[index]->get_age() << std::endl;
std::cout << "Phone number: " << people[index]->get_phone() << std::endl;
std::cout << "Name: " << people[index]->get_name() << std::endl;
std::cout << "Address: " << people[index]->get_address() << std::endl;
std::cout << "Bank number: " << people[index]->get_bankAccount() << std::endl;
std::cout << "Bank: " << people[index]->get_bank() << std::endl;
std::cout << "Client ID: " << people[index]->get_clientId() << std::endl;
std::cout << "Spendings: " << people[index]->get_spendings() << std::endl;
std::cout << "Purchas History: " << people[index]->get_purchase_history() << std::endl;
std::cout << "Notes: " << people[index]->get_notes() << std::endl;
std::cout << "Referrals: " << people[index]->get_referrals() << std::endl;
}
}
} else if (parts[0] == "set"){
int index;
for (int i = 0; i < get_curr_size(); i++){
if (people[i]->get_name() == parts[2]){
index = i;
}
}
if (parts[1] == "age"){
int age;
std::string input;
std::cout << "Enter the age: ";
std::cin >> input;
try {
age = std::stoi(input); // Convert input to an integer
people[index]->set_age(age);
std::cout << "Age was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Age set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Age set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "phonenumber"){
int phoneNumber;
std::string input;
std::cout << "Enter phone number: ";
std::cin >> input;
try {
phoneNumber = std::stoi(input);
people[index]->set_phone(phoneNumber);
std::cout << "Phone was number set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Age set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Age set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "address"){
std::string address;
std::cout << "Enter address: ";
std::getline(std::cin, address);
people[index]->set_address(address);
std::cout << "address was set successfully.\n";
}
if (parts[1] == "id") {
int ID;
std::string input;
std::cout << "Enter ID: ";
std::cin >> input;
try {
ID = std::stoi(input);
people[index]->set_ID(ID);
std::cout << "ID was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! ID set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! ID set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "hourlysalary") {
float hourlySalary;
std::string input;
std::cout << "Enter Hourly Salary: ";
std::cin >> input;
try {
hourlySalary = std::stof(input);
people[index]->set_salary_hourly(hourlySalary);
std::cout << "Hourly Salary was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Hourly Salary set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Hourly Salary set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "weeklyhours") {
float weeklyHours;
std::string input;
std::cout << "Enter Weekly Hours: ";
std::cin >> input;
try {
weeklyHours = std::stof(input);
people[index]->set_hours_weekly(weeklyHours);
std::cout << "Weekly Hours was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Weekly Hours set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Weekly Hours set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "attendance"){
int day;
int attendance;
std::cout << "Enter day (Monday = 1 to Sunday = 7): ";
std::cin >> day;
if (day < 1 || day > 7) {
std::cout << "Next time enter a proper number between 1 to 7 (Monday = 1 to Sunday = 7): ";
return;
}
std::cout << "Did employee attend that day? (yes = 1/no = 0): ";
std::cin >> attendance;
if (attendance != 1 && attendance != 0) {
std::cout << "Next time enter a proper attendance response (yes = 1/no = 0): ";
return;
}
day = day - 1;
people[index]->set_attendance(attendance, day);
std::cout << "Attendance was set successfully.\n";
}
if (parts[1] == "datejoined"){
std::string dj;
std::cout << "Enter Date Joined: ";
std::getline(std::cin, dj);
people[index]->set_date_joined(dj);
std::cout << "Date joined was set successfully.\n";
}
if (parts[1] == "performance") {
int performance;
std::cout << "Enter employee Performance out of 10: ";
std::cin >> performance;
if (performance > 0 && performance <= 10) {
people[index]->set_performance(performance);
std::cout << "Performance was set successfully.\n";
} else {
std::cout << "Performance set failed! Enter a value between 1 and 10.\n";
}
}
if (parts[1] == "position"){
std::string position;
std::cout << "Enter the employee's position: ";
std::getline(std::cin, position);
people[index]->set_position(position);
std::cout << "Position was set successfully.\n";
}
if (parts[1] == "banknumber") {
int bankNumber;
std::string input;
std::cout << "Enter Customer's bank number: ";
std::cin >> input;
try {
bankNumber = std::stoi(input);
people[index]->set_bankAccount(bankNumber);
std::cout << "Customer's bank number was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Customer's bank number set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Customer's bank number set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "bank"){
std::string bank;
std::cout << "Enter the customer's bank: ";
std::getline(std::cin, bank);
people[index]->set_bank(bank);
std::cout << "Customer's bank was set successfully.\n";
}
// std::cout << "Client ID: " << people[index]->get_clientId() << std::endl;
if (parts[1] == "spendings") {
int spendings;
std::string input;
std::cout << "Enter Customer's spendings: ";
std::cin >> input;
try {
spendings = std::stoi(input);
people[index]->set_spendings(spendings);
std::cout << "Customer's spendings was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Customer's spendings set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Customer's spendings set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "purchasehistory"){
std::string p_history;
std::cout << "Enter the Purchase History: ";
std::getline(std::cin, p_history);
people[index]->set_purchase_history(p_history);
std::cout << "Purchase History was set successfully.\n";
}
if (parts[1] == "notes"){
std::string notes;
std::cout << "Enter the notes about customer: ";
std::getline(std::cin, notes);
people[index]->set_notes(notes);
std::cout << "Customer Notes was set successfully.\n";
}
if (parts[1] == "finisheddesigns"){
std::string fin_des;
std::cout << "Enter the Finished Designs: ";
std::getline(std::cin, fin_des);
people[index]->set_finished(fin_des);
std::cout << "Finished Designs was set successfully.\n";
}
if (parts[1] == "currentdesigns"){
std::string cur_des;
std::cout << "Enter the Current Designs: ";
std::getline(std::cin, cur_des);
people[index]->set_design_current(cur_des);
std::cout << "Current Designs was set successfully.\n";
}
if (parts[1] == "turnover") {
int Turnover;
std::string input;
std::cout << "Enter Turnover: ";
std::cin >> input;
try {
Turnover = std::stoi(input);
people[index]->set_turnover(Turnover);
std::cout << "Turnover was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Turnover set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Turnover set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "profit") {
int Profit;
std::string input;
std::cout << "Enter Profit: ";
std::cin >> input;
try {
Profit = std::stoi(input);
people[index]->set_profit(Profit);
std::cout << "Profit was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Profit set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Profit set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "budget") {
int Budget;
std::string input;
std::cout << "Enter Budget: ";
std::cin >> input;
try {
Budget = std::stoi(input);
people[index]->set_budget(Budget);
std::cout << "Budget was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Profit set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Profit set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "expense") {
int Expense;
std::string input;
std::cout << "Enter expenses: ";
std::cin >> input;
try {
Expense = std::stoi(input);
people[index]->set_expense(Expense);
std::cout << "Expenses was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Expenses set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Expenses set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "trained") {
int trained;
std::string input;
std::cout << "Enter number of trained employees: ";
std::cin >> input;
try {
trained = std::stoi(input);
people[index]->set_trained(trained);
std::cout << "Number of trained employees was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Number of trained employees set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Number of trained employees set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "hired") {
int hired;
std::string input;
std::cout << "Enter number of trained employees: ";
std::cin >> input;
try {
hired = std::stoi(input);
people[index]->set_hired(hired);
std::cout << "Number of hired employees was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Number of hired employees set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Number of hired employees set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "fired") {
int fired;
std::string input;
std::cout << "Enter number of trained employees: ";
std::cin >> input;
try {
fired = std::stoi(input);
people[index]->set_fired(fired);
std::cout << "Number of fired employees was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Number of fired employees set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Number of fired employees set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "retired") {
int retired;
std::string input;
std::cout << "Enter number of retired employees: ";
std::cin >> input;
try {
retired = std::stoi(input);
people[index]->set_retired(retired);
std::cout << "Number of retired employees was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Number of retired employees set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Number of retired employees set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "investment") {
float investment;
std::string input;
std::cout << "Enter investment amount: ";
std::cin >> input;
try {
investment = std::stof(input);
people[index]->set_amount_of_investment(investment);
std::cout << "Investment was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Investment set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Investment set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "password"){
std::string Password;
std::string check;
std::cout << "Enter the password: ";
std::cin >> Password;
std::cout << "Enter password again: ";
std::cin >> check;
if (check != Password){
std::cout << "Password entered didn't match.\n";
return;
}
people[index]->set_password(Password);
std::cout << "Password was set successfully.\n";
}
if (parts[1] == "certification"){
std::string Certification;
std::cout << "Enter the Employee's certification: ";
std::getline(std::cin, Certification);
people[index]->set_certification(Certification);
std::cout << "Certification was set successfully.\n";
}
if (parts[1] == "carscomplete") {
int complete;
std::string input;
std::cout << "Enter number of cars completed: ";
std::cin >> input;
try {
complete = std::stoi(input);
people[index]->set_cars_complete(complete);
std::cout << "Number of cars completed was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Number of cars completed set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Number of cars completed set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "success") {
float success;
std::string input;
std::cout << "Enter the Employee's success rate: ";
std::cin >> input;
try {
success = std::stof(input);
people[index]->set_success_rate(success);
std::cout << "Success rate was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Success rate set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Success rate set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "finishedresearch"){
std::string fin_res;
std::cout << "Enter Finished research: ";
std::getline(std::cin, fin_res);
people[index]->set_finished(fin_res);
std::cout << "Finished research was set successfully.\n";
}
if (parts[1] == "currentresearch"){
std::string cur_res;
std::cout << "Enter Employee's current research: ";
std::getline(std::cin, cur_res);
people[index]->set_research(cur_res);
std::cout << "Current research was set successfully.\n";
}
if (parts[1] == "expertise"){
std::string Expertise;
std::cout << "Enter the Employee's expertise: ";
std::getline(std::cin, Expertise);
people[index]->set_expertise(Expertise);
std::cout << "Expertise was set successfully.\n";
}
if (parts[1] == "conversion") {
float Conversion;
std::string input;
std::cout << "Enter the Conversion rate: ";
std::cin >> input;
try {
Conversion = std::stof(input);
people[index]->set_conversion_rate(Conversion);
std::cout << "Conversion rate was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Conversion rate set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Conversion rate set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "sold") {
int sold_cars;
std::string input;
std::cout << "Enter the number of cars sold: ";
std::cin >> input;
try {
sold_cars = std::stoi(input);
people[index]->set_cars_sold(sold_cars);
std::cout << "Number of cars sold was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Number of cars sold set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Number of cars sold set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "revenue") {
float Revenue;
std::string input;
std::cout << "Enter Revenue: ";
std::cin >> input;
try {
Revenue = std::stof(input);
people[index]->set_revenue(Revenue);
std::cout << "Revenue was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Revenue set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Revenue set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "languages"){
std::string languages;
std::cout << "Enter the Employee's languages: ";
std::getline(std::cin, languages);
people[index]->set_language(languages);
std::cout << "Languages was set successfully.\n";
}
if (parts[1] == "finishedprojects"){
std::string fin_proj;
std::cout << "Enter the Employee's Finished projects: ";
std::getline(std::cin, fin_proj);
people[index]->set_finished(fin_proj);
std::cout << "Finished projects was set successfully.\n";
}
if (parts[1] == "currentprojects"){
std::string cur_proj;
std::cout << "Enter the Employee's Current projects: ";
std::getline(std::cin, cur_proj);
people[index]->set_projects_current(cur_proj);
std::cout << "Current projects was set successfully.\n";
}
if (parts[1] == "cargoamount") {
int amount_cargo;
std::string input;
std::cout << "Enter Amount of cargo: ";
std::cin >> input;
try {
amount_cargo = std::stof(input);
people[index]->set_amount_of_cargo(amount_cargo);
std::cout << "Amount of cargo was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Amount of cargo set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Amount of cargo set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "annualcost") {
float Annual_cost;
std::string input;
std::cout << "Enter Revenue: ";
std::cin >> input;
try {
Annual_cost = std::stof(input);
people[index]->set_cost_annually(Annual_cost);
std::cout << "Annual cost was set successfully.\n";
} catch (const std::invalid_argument& e) {
std::cout << "Invalid input! Annual cost set failed. " << e.what() << std::endl;
} catch (const std::out_of_range& e) {
std::cout << "Input out of range! Annual cost set failed. " << e.what() << std::endl;
}
}
if (parts[1] == "cargo"){
std::string cargo;
std::cout << "Enter the cargo name: ";
std::getline(std::cin, cargo);
people[index]->set_cargo(cargo);
std::cout << "Cargo name(s) was set successfully.\n";