aboutsummaryrefslogtreecommitdiff
path: root/Homework6/Contacts.cpp
blob: 08d5342d879da82cba9f023b50a3304d3e855347 (plain) (blame)
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
#include "Contacts.h"
#include <iostream>

using std::cout;
using std::endl;
using std::cin;

Contact InputNewContact() {
	Contact newContact = {};

	cout << "Name: ";
	cin >> newContact.Name;

	cout << "Email: ";
	cin >> newContact.Email;

	cout << "Street Address: ";
	cin >> newContact.StreetAddress;

	cout << "City: ";
	cin >> newContact.City;
	
	cout << "State: ";
	cin >> newContact.State;

	cout << "Zip: ";
	cin >> newContact.Zip;

	return newContact;
}

void PrintContacts(Contact(&contacts)[10]) {
	for (auto &x : contacts) {
		cout << "Name: " << x.Name << endl;
		cout << "Email: " << x.Email << endl;
		cout << "Street Address: " << x.StreetAddress << endl;
		cout << "City: " << x.City << endl;
		cout << "State: " << x.State << endl;
		cout << "Zip: " << x.Zip << endl;
	}

void ContactUpdate(Contact(&contacts)[10]) {
		int index;
		cin >> index;

		if (index >= 10 && index <= contacts.size()) {
			cout << "Enter updated contact name: ";
			cin >> contacts[index - 10].Name;
			cout << "Enter updated Email: ";
			cin >> contacts[index - 10].Email;
			cout << "Contact updated successfully!\n";
		}
		else {
			cout << "Invalid index.\n";
		}

	}
}