aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNataliia Brown <[email protected]>2024-02-14 01:15:13 -0800
committerNataliia Brown <[email protected]>2024-02-14 01:15:13 -0800
commitc56343451b7be278d6435e5c95b95522e2304a62 (patch)
tree1d304169ac2414db24e8e4645a0dd71653a983f6
parentAdded all files (diff)
downloadhomework-5-natabrown-c56343451b7be278d6435e5c95b95522e2304a62.tar.xz
homework-5-natabrown-c56343451b7be278d6435e5c95b95522e2304a62.zip
Added vector and printing
-rw-r--r--Homework 5/Homework 5/Contacts.cpp29
-rw-r--r--Homework 5/Homework 5/Contacts.h14
-rw-r--r--Homework 5/Homework 5/program.cpp195
3 files changed, 234 insertions, 4 deletions
diff --git a/Homework 5/Homework 5/Contacts.cpp b/Homework 5/Homework 5/Contacts.cpp
index 677be06..e80d306 100644
--- a/Homework 5/Homework 5/Contacts.cpp
+++ b/Homework 5/Homework 5/Contacts.cpp
@@ -6,7 +6,34 @@
#include "Contacts.h"
#include <iostream>
+#include <vector>
using std::cout;
using std::cin;
-using std::endl; \ No newline at end of file
+using std::endl;
+
+Contact InputPersonalInfo()
+{
+ Contact user = {};
+
+ cout << "\Name: ";
+ cin >> user.Name;
+
+ cout << "Email: ";
+ cin >> user.Email;
+
+ cout << "Street Adress: ";
+ cin >> user.StreetAdress;
+
+ cout << "City: ";
+ cin >> user.City;
+
+ cout << "State: ";
+ cin >> user.State;
+
+ cout << "Zip: ";
+ cin >> user.Zip;
+
+ system("cls");
+ return user;
+}
diff --git a/Homework 5/Homework 5/Contacts.h b/Homework 5/Homework 5/Contacts.h
index 223dbba..b5f92ec 100644
--- a/Homework 5/Homework 5/Contacts.h
+++ b/Homework 5/Homework 5/Contacts.h
@@ -3,6 +3,20 @@
+struct Contact
+{
+ char Name[25] = {};
+ char Email[100] = {};
+ char StreetAdress[35] = {};
+ char City[30] = {};
+ char State[2] = {};
+ int Zip = 0;
+};
+
+Contact InputPersonalInfo();
+
+
+
diff --git a/Homework 5/Homework 5/program.cpp b/Homework 5/Homework 5/program.cpp
index 677be06..e507f81 100644
--- a/Homework 5/Homework 5/program.cpp
+++ b/Homework 5/Homework 5/program.cpp
@@ -6,7 +6,196 @@
#include "Contacts.h"
#include <iostream>
+#include<list>
+#include <vector>
+
+using namespace std;
+
+
+int Menu() {
+ cout << "Please choose option from 1 to 4:" << endl << "1. Add New Contact" << endl << "2. Update Contact" << endl
+ << "3. Print All Contacts" << endl << "4. Exit" << endl;
+ return 0;
+}
+
+
+void main(){
+
+ Menu();
+
+ int i;
+ cin >> i;
+
+ vector<Contact>vecContacts;
+
+ while (i != 4) {
+ //system("cls");
+ if (i == 1)
+ {
+ system("cls");
+ cout << "1: " << endl;
+
+ vecContacts.push_back(InputPersonalInfo());
+
+
+ for (int count = 0; count < vecContacts.size(); count++)
+ {
+ cout << "\nName: " << vecContacts[count].Name << "\nEmail: " << vecContacts[count].Email << "\nStreet Adress: " << vecContacts[count].StreetAdress << "\nCity: $" << vecContacts[count].City << "\State: " << vecContacts[count].State << "\nZip: " << vecContacts[count].Zip << endl;
+ }
+ cout << endl;
+
+
+ int j;
+ Menu();
+
+ cin >> j;
+ i = j;
+
+
+
+ //- Create new struct and add it to the list*/
+
+ }
+ else if (i == 2)
+ {
+ //system("cls");
+ cout << "2: " << endl;
+ /*UpdateContact()
+
+ UserDob newUser = InputPersonalInfo();
+ PrintUserInfo(newUser); - Update all fields for the same email*/
+ }
+ else if (i == 3)
+ {
+ //system("cls");
+ cout << "3: " << endl;
+ /*PrintFibonacci(i); - print all contacts*/
+ }
+ system("cls");
+ int j;
+ Menu();
+
+ cin >> j;
+ i = j;
+
+
+
+ }
+
+
+
+
+}
+
+
+
+
+
+
+
+
+
+
+//void Print100(size_t n) {
+// for (int j = 0; j <= n; j++) {
+// cout << j << " ";
+// }
+// cout << endl;
+//}
+//
+//void PrintFibonacci(size_t n) {
+// int k, t1 = 0, t2 = 1, nextTerm = 0;
+//
+// cout << "Enter the number of terms: ";
+// cin >> k;
+//
+// cout << "Fibonacci Series: ";
+//
+// for (int i = 1; i <= k; ++i) {
+//
+// if (i == 1) {
+// cout << t1 << " ";
+// continue;
+// }
+// if (i == 2) {
+// cout << t2 << " ";
+// continue;
+// }
+// nextTerm = t1 + t2;
+// t1 = t2;
+// t2 = nextTerm;
+//
+// cout << nextTerm << " ";
+// }
+//
+//
+//}
+//
+//struct UserDob
+//{
+// int day;
+// int month;
+// int year;
+//};
+//
+//UserDob InputPersonalInfo()
+//{
+// UserDob user = {};
+//
+// cout << "\nDay: ";
+// cin >> user.day;
+//
+// cout << "Month: ";
+// cin >> user.month;
+//
+// cout << "Year: ";
+// cin >> user.year;
+//
+// return user;
+//
+//}
+//
+//void PrintUserInfo(UserDob newUser) {
+//
+// cout << "User's DOB: " << newUser.month << "/" << newUser.day << "/" << newUser.year << endl;
+//}
+//
+//int main() {
+// int i;
+// Menu();
+// cin >> i;
+//
+//
+// while (i != 4) {
+// system("cls");
+// if (i == 1)
+//
+// {
+// cout << "Enter the number for Print 100 function: ";
+// int n;
+// cin >> n;
+// Print100(n);
+// }
+// else if (i == 2)
+// {
+// UserDob newUser = InputPersonalInfo();
+// PrintUserInfo(newUser);
+// }
+// else if (i == 3)
+// {
+// PrintFibonacci(i);
+// }
+//
+//
+// int j;
+// Menu();
+//
+// cin >> j;
+// i = j;
+// }
+//
+// return 0;
+//}
+
+
-using std::cout;
-using std::cin;
-using std::endl; \ No newline at end of file