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
| #include "mediator.h" #include "user.h"
int main(int argc, char *argv[]) { ChatService chatService; GeneralUser userA("13579", &chatService); GeneralUser userB("02468", &chatService); GeneralUser userC("12345", &chatService);
chatService.registerUser(&userA); chatService.registerUser(&userB); chatService.registerUser(&userC);
userA.send("02468", "Hello, 02468!"); userA.send("12345", "Hello, 12345!");
userB.send("13579", "Hello, 13579!"); userB.send("12345", "Hello, 12345!");
userC.send("13579", "Hello, 13579!"); userC.send("02468", "Hello, 02468!");
chatService.unregisterUser(&userC);
userA.send("02468", "Hello, 02468!"); userA.send("12345", "Hello, 12345!");
userB.send("13579", "Hello, 13579!"); userB.send("12345", "Hello, 12345!");
return 0; }
|