-
Notifications
You must be signed in to change notification settings - Fork 1
/
Option5.cpp
114 lines (97 loc) · 2.72 KB
/
Option5.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
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include "Person.h"
#include "PersonFile.h"
#include "Vehicle.h"
#include "VehicleFile.h"
using namespace std;
Person SearchBySSN(const string & aString);
void DisplayPerson();
Vehicle VSearchBySSN(const string & aString);
void DisplayVehicle();
string UserWait();
void Option5()
{
Person * pPerson = new Person;
PersonFile * pPersonFile = new PersonFile;
Vehicle * pVehicle = new Vehicle;
VehicleFile * pVehicleFile = new VehicleFile;
string inSSN;
string deleteOpt;
while(true)
{
system("clear");
cout << "\t\t\t* * * Option 5: Search by SSN to Delete the Record* * *" << endl << endl;
cout << "\t\tEnter a Social Security Number to DELETE Record (or Q to Quit): ";
getline(cin, inSSN);
cin.sync();
if(inSSN[0] == 'q' || inSSN[0] == 'Q')
{
break;
}
*pPerson = pPersonFile->SearchBySSN(inSSN);
*pVehicle = pVehicleFile->VSearchBySSN(inSSN);
if(!(pPerson->IsFound()))
{
cout << endl << endl;
cout << "\t\tSocial Security Number was not found" << endl;
UserWait();
continue;
}
if(pPerson->IsFound() && pVehicle->IsFound())
{
cout << endl << endl;
pPerson->DisplayPerson();
cout << endl << endl;
pVehicle->DisplayVehicle();
cout << endl << endl << "\t\tIs this the Record you wish to Delete?(Y/N):";
getline(cin, deleteOpt);
cin.sync();
if(deleteOpt[0] == 'y' || deleteOpt[0] == 'Y')
{
pPerson->SetDeleted(true);
pVehicle->SetDeleted(true);
pPersonFile->UpdatePerson(*pPerson);
pVehicleFile->UpdateVehicle(*pVehicle);
system("clear");
cout << endl << endl << "\t\tRecord was Deleted successfully." << endl;
UserWait();
}
else
{
system("clear");
cout << endl << endl << "\t\tRecord was NOT deleted." << endl;
UserWait();
}
}
if(pPerson->IsFound() && !(pVehicle->IsFound()))
{
cout << endl << endl;
pPerson->DisplayPerson();
cout << endl << endl << "\t\tNo Vehicle";
cout << endl << endl << "\t\tIs this the Record you wish to Delete?(Y/N):";
getline(cin, deleteOpt);
cin.sync();
if(deleteOpt[0] == 'y' || deleteOpt[0] == 'Y')
{
pPerson->SetDeleted(true);
pPersonFile->UpdatePerson(*pPerson);
system("clear");
cout << endl << endl << "\t\tRecord was Deleted successfully." << endl;
UserWait();
}
else
{
system("clear");
cout << endl << endl << "\t\tRecord was NOT deleted." << endl;
UserWait();
}
}
}
delete pPerson;
delete pPersonFile;
delete pVehicle;
delete pVehicleFile;
return;
}