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
|
#include "Contacts.h"
#include <iostream>
#include <list>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
int menu()
{
int c;
cout << "1. Enter a name\n";
cout << "2. Delete a name\n";
cout << "3. List the file\n";
cout << "4. Quit\n";
do {
cout <<"\nEnter your choice: ";
cin >> c;
} while (c < 0 || c>4);
return c;
}
char addNew(contact newContact[], size_t MAX, size_t t)
{
for (size_t i = t ; i < MAX; i++)
{
newContact[i].id = i+1;
newContact[i].count = t;
cin.ignore(1000, '\n');
cout << "Please enter each piece of information when you are prompted to" << endl;
cout << "enter name: " << endl;
cin.getline(newContact[i].Name, 25);
cout << "enter Email: " << endl;
cin.getline(newContact[i].Email, 100);
cout << "enter Street Address: " << endl;
cin.getline(newContact[i].StreetAddress, 35);
cout << "enter city: " << endl;
cin.getline(newContact[i].City, 30);
cout << "enter State as two letter abbreviation: " << endl;
cin.getline(newContact[i].State, 3);
cout << "Please enter the next value as a series of numbers" << endl;
cout << "enter Zip: " << endl;
cin >> newContact[i].Zip;
break;
}
//cout << newContact[i]->Name << "\n" << newContact[i]->Email << "\n" << newContact[i]->StreetAddress << "\n" << newContact[i]->City << "\n" << newContact[i]->State << "\n" << newContact[i]->Zip << endl;
return 0;
}
// print contact i
// name:
// email
// address
// city
// state
// zip
void update(contact newContact[], size_t MAX)
{
cout << "select a contact to update based on their position in the list (check print all contacts for list position)" << endl;
int c = 0;
cin >> c;
int t = c - 1;
for (size_t i = t; i < MAX;)
{
cin.ignore(1000, '\n');
cout << "Please enter each piece of information when you are prompted to" << endl;
newContact[i].id = c;
cout << "enter name: " << endl;
cin.getline(newContact[i].Name, 25);
cout << "enter Email: " << endl;
cin.getline(newContact[i].Email, 100);
cout << "enter Street Address: " << endl;
cin.getline(newContact[i].StreetAddress, 35);
cout << "enter city: " << endl;
cin.getline(newContact[i].City, 30);
cout << "enter State as two letter abbreviation: " << endl;
cin.getline(newContact[i].State, 3);
cout << "Please enter the next value as a series of numbers" << endl;
cout << "enter Zip: " << endl;
cin >> newContact[i].Zip;
break;
}
}
void printAll(contact newContact[], size_t MAX)
{
for (int i = 0; i < MAX; ++i)
{
/*for (int t = -1; t < newContact[i].id;) {
break;
}*/
if (newContact[i].id == 0) {
break;
}
if (newContact[i].id < 0) {
break;
}
if (newContact[i].id > MAX) {
break;
}
cout << "List number: " << newContact[i].id << endl;
cout << "name: " << newContact[i].Name << endl;
cout << "Email: " << newContact[i].Email << endl;
cout << "Address: " << newContact[i].StreetAddress << endl;
cout << "city: " << newContact[i].City << endl;
cout << "state: " << newContact[i].State << endl;
cout << "Zip: " << newContact[i].Zip << endl;
}
}
void contact_double(contact*& newContact, size_t& MAX, size_t t)
{
//supposedly doubles length. doesnt work.
//current ideas: add if loop to whole main with the id counter t and if length of newContact = max double the length.
//current problems: using const size_t max prevents editing size for the whole function, and it resets as soon as the while loop loops or leaves the scope of the if statement.
contact* doubleContact = new contact[MAX * 2];
for (auto a = 0u; a < MAX * 2; ++a)
{
doubleContact[a] = newContact[a];
}
delete[] newContact;
newContact = doubleContact;
MAX = MAX * 2;
//return newContact[MAX];
}
void delete_contact(contact newContact[])
{
//Work in progress, add BOOL (0) to struct, when this is selected print id list with respective names
//then take input of id list number and set BOOL to 1
//add to new part to addNew: if bool != 0 then copy and paste update code w/addNew couts
}
|