-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecords.cpp
More file actions
133 lines (111 loc) · 2.89 KB
/
Records.cpp
File metadata and controls
133 lines (111 loc) · 2.89 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: Records.cpp
* Author: rghosh
*
* Created on February 1, 2020, 1:04 PM
*/
#include "Records.h"
#include <iostream>
using namespace std;
Records::Records() {
}
Records::Records(const Records& orig) {
Name = orig.Name;
Rank = orig.Rank;
City = orig.City;
State = orig.State;
Zip = orig.Zip;
Employees = orig.Employees;
}
Records::~Records() {
}
void Records::writeRecord(fstream &file, string name)
{
cout << "Please enter what you would like to update (re-enter same data if you wish to leave it as is):" << endl;
cout << "Rank: ";
cin >> Rank;
if (Rank.length() > 10) {
Rank = Rank.substr(0,10);
}
cout << "City: ";
cin.ignore();
getline(cin, City);
if (City.length() > 20) {
City = City.substr(0,20);
}
replace(City.begin(), City.end(), ' ', '_');
cout << "State: ";
getline(cin, State);
if (State.length() > 10) {
State = State.substr(0,10);
}
replace(State.begin(), State.end(), ' ', '_');
cout << "Zip: ";
cin >> Zip;
if (Zip.length() > 10) {
Zip = Zip.substr(0,10);
}
cout << "Employees: ";
cin >> Employees;
if (Employees.length() > 10) {
Employees = Employees.substr(0,10);
}
file << setw(40) << left << name;
file << setw(10) << left << Rank;
file << setw(20) << left << City;
file << setw(10) << left << State;
file << setw(10) << left << Zip;
file << setw(10) << left << Employees << endl;
}
void Records::writeNewRec(fstream &file)
{
file << setw(40) << left << Name;
file << setw(10) << left << Rank;
file << setw(20) << left << City;
file << setw(10) << left << State;
file << setw(10) << left << Zip;
file << setw(10) << left << Employees << endl;
}
void Records::writeBlank(fstream &file)
{
file << setw(40) << left << "BLANK";
file << setw(10) << left << "BLANK";
file << setw(20) << left << "BLANK";
file << setw(10) << left << "BLANK";
file << setw(10) << left << "BLANK";
file << setw(10) << left << "BLANK" << endl;
}
void Records::readRecord(fstream &file)
{
file >> Name >> Rank >> City >> State >> Zip >> Employees;
}
string Records::getName() {
return Name;
}
string Records::getRank() {
return Rank;
}
string Records::getCity() {
return City;
}
string Records::getState() {
return State;
}
string Records::getZip() {
return Zip;
}
string Records::getEmployees() {
return Employees;
}
void Records::setRecord(fstream &file) {
file >> Name >> Rank >> City >> State >> Zip >> Employees;
}
void Records::printRecord() {
cout << Name << " " << Rank << " " << City << " " << State << " " << Zip << " " <<
Employees << endl;
}