-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
140 lines (123 loc) · 3.41 KB
/
main.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <iostream>
#include "DlinkedList.h"
#include "DlinkedList.cpp"
#include "wall.h"
#include "user.h"
#include <string>
using namespace std;
int main(){
/*
*
*
cin cout program code
*
*
*/
UserNetwork facebook;
facebook.readNetwork("infile.txt");
int running, main_menu_option = 0;
string name, username, password, phonenumber, post;
User *current_user = NULL;
//main menu of the social app
cout << "Welcome the social network" << endl;
while(running == 0){
while(main_menu_option == 0){
//main menu
cout << "please type in a number from these options" << endl;
cout << "1. Login" << endl;
cout << "2. Register Account" << endl;
cout << "3. Quit" << endl;
cin >> main_menu_option;
cin.ignore(1,'\n');
if(!main_menu_option){
cin.clear();
cin.ignore();
}
if(main_menu_option == 0 || main_menu_option > 3 || main_menu_option < 0){
cout << "please choose the following options" << endl;
main_menu_option = 0;
}
if(main_menu_option == 1){
//login
cout << "Enter your username" << endl;
getline(cin, username);
cout << "Enter your password" << endl;
getline(cin, password);
current_user = (facebook.login(username, password));
if(current_user == NULL){
main_menu_option = 0;
}
}
else if(main_menu_option == 2){
//register
cout << "Enter your username: ";
getline(cin, username);
cout << "Enter a password: ";
getline(cin, password);
cout << "Enter a name: ";
getline(cin, name);
cout << "Enter your phone number: ";
getline(cin, phonenumber);
if(facebook.validateUser(username) == 1){
User new_user(username, password, name, phonenumber);
facebook.add(new_user);
current_user = &new_user;
cout << "You have successfully created a user" << endl;
cout << "Logging into the new user account" << endl << endl;
}else{
cout << "Duplicate username, failed to sign up" << endl << endl;
main_menu_option = 0;
}
}
else if(main_menu_option == 3){
//exit(EXIT_SUCCESS);
return 1;
//quit
}
}
//resets menu
main_menu_option = 0;
//for logged in users
if(current_user != NULL){
cout << "You have logged in, " << current_user->getName() << endl;
while(main_menu_option == 0){
cout << "Chose an option" << endl;
cout << "1. Display my wall" << endl;
//cout << "2. Add post" << endl;
cout << "2. Logout" << endl;
cout << "3. Quit" << endl;
cin >> main_menu_option;
if(!main_menu_option){
cin.clear();
cin.ignore();
}
if(main_menu_option == 0 || main_menu_option > 3 || main_menu_option < 0){
cout << "please choose the following options" << endl << endl;
main_menu_option = 0;
}
if(main_menu_option == 1){
cout << endl << "Your wall: " << endl;
cout << current_user->getWall() << endl;
main_menu_option = 0;
}
// else if(main_menu_option == 2){
// cout << "write your post (press enter to submit): ";
// cin.ignore();
// getline(cin, post);
// current_user->createWallPost(post);
// cout << "post added successfully" << endl;
// main_menu_option = 0;
// }
else if(main_menu_option == 2){
cout << "logged out successfully" << endl;
main_menu_option = 0;
current_user = NULL;
break; //exits this while loop
}
else if(main_menu_option == 3){
return 1;
}
}
}
}
}