-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (69 loc) · 2.08 KB
/
Copy pathmain.cpp
File metadata and controls
77 lines (69 loc) · 2.08 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
#include <iostream>
#include "authentication.h"
#include "message.h"
using namespace std;
int main() {
Messenger chat;
int loggedInUserId = login();
bool running = true;
while (running) {
cout << "\nMenu:\n"
<< "1. Send Simple Message\n"
<< "2. Send Post Message\n"
<< "3. Send Vote Message\n"
<< "4. Display Chat\n"
<< "5. Exit\n";
cout << "Choose an option: ";
int option;
cin >> option;
switch (option) {
case 1: {
char msg[200];
cout << "Enter your message: ";
cin.ignore();
cin.getline(msg, 200);
SimpleMessage *message = new SimpleMessage(loggedInUserId, msg);
chat.addMessage(message);
break;
}
case 2: {
char msg[200], imgPath[200];
cout << "Enter your message: ";
cin.ignore();
cin.getline(msg, 200);
cout << "Enter image path: ";
cin.getline(imgPath, 200);
PostMessage *post = new PostMessage(loggedInUserId, msg, imgPath);
chat.addMessage(post);
break;
}
case 3: {
char title[200], options[10][200];
int optionCount;
cout << "Enter vote title: ";
cin.ignore();
cin.getline(title, 200);
cout << "How many options (max 10): ";
cin >> optionCount;
cin.ignore();
for (int i = 0; i < optionCount; ++i) {
cout << "Enter option " << i + 1 << ": ";
cin.getline(options[i], 200);
}
VoteMessage *vote = new VoteMessage(loggedInUserId, title, options, optionCount);
chat.addMessage(vote);
break;
}
case 4:
cout << "\nChat Messages:\n";
chat.displayChat();
break;
case 5:
running = false;
break;
default:
cout << "Invalid option. Try again." << endl;
}
}
return 0;
}