Repository navigation
Expand file tree
/
Copy pathMain.cpp
More file actions
140 lines (115 loc) · 3.07 KB
/
Copy pathMain.cpp
File metadata and controls
140 lines (115 loc) · 3.07 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
134
135
136
137
138
139
140
#include "Username.h"
using std::string;
#include "sqliteDatabase.h"
#include <iostream>
using std::cout;
using std::cin;
#include <ctime>
using std::time;
void registration(string firstName, string lastName, string password, string identification) {
cout << "Please enter your first name and then press enter: ";
cin >> firstName;
cout << "\n";
cout << "Please enter your last name and then press enter: ";
cin >> lastName;
cout << "Please enter your password and press enter: ";
cin >> password;
Registration p1(firstName, lastName, password);
{
Username user(firstName, lastName, password, firstName + identification);
string username = user.getUser();
cout << username + "\n";
data(username, firstName, lastName, password);
}
}
string login(string username, string password) {
bool again = true;
while (again == true) {
cout << "Please enter your username: ";
cin >> username;
cout << "Please enter your password and press enter: ";
cin >> password;
if (login_check(username, password)) {
again = false;
}
}
return username;
}
string writeMessages() {
string recieverName;
bool found = true;
while (found) {
cout << "Who do you want to send the message to? ";
cin >> recieverName;
if (check(recieverName) == true) {
cout << "User account found\n";
found = false;
}
else {
cout << "User account not found, please try again\n";
}
}
return recieverName;
}
string receiverCheck() {
string recieverName;
bool found = true;
while (found) {
cout << "Whose message do you want to read? ";
cin >> recieverName;
if (check(recieverName) == true) {
cout << "User account found\n";
found = false;
}
else {
cout << "User account not found, please try again\n";
}
}
return recieverName;
}
int main() {
string firstName;
string lastName;
string password;
char currentUser;
string username;
string message;
char readOrWrite;
string senderName;
string recieverName;
srand((signed)time(0));
int i = rand();
string identification = std::to_string (i);
//Creat_users_table();
users_table();
//Create_messages_table();
message_table();
//write another function add_read_receipt_column();
message_table_edit();
cout << "Do you already have an account? [Y/N]";
cin >> currentUser;
if (currentUser == 'Y' || currentUser == 'y') {
senderName = login(username, password);
}
else {
registration(firstName, lastName, password, identification);
}
//Do you want to read or write a message. Make a wrap around with an if statement
cout << "Type 'R' if you would like to read a message or type 'W' if you would like to write a message: ";
cin >> readOrWrite;
if (readOrWrite == 'W' || readOrWrite == 'w') {
recieverName = writeMessages();
cout << "You can now write your message: ";
cin.ignore(1, '\n');
std::getline(cin, message);
store_message(senderName, recieverName, message);
}
if (readOrWrite == 'R' || readOrWrite == 'r') {
message_count(senderName);
//Show the pending messages?
recieverName = receiverCheck();
read_messages(senderName, recieverName);
read_receipt(recieverName);
}
return 0;
}