-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
67 lines (63 loc) · 1.64 KB
/
Main.cpp
File metadata and controls
67 lines (63 loc) · 1.64 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
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include "ChatClient.h"
using namespace std;
int main()
{
ifstream workingfile;
workingfile.open("DataBase.txt");
string name;
getline(workingfile,name);
int year;
workingfile >> year;
string temp;
int basesize = -1;
int maincounter = -1;
getline(workingfile, temp); getline(workingfile, temp);
workingfile >> basesize;
getline(workingfile, temp);
ChatUser *base[UsersCountSize];
getline(workingfile, temp); getline(workingfile, temp);
while (workingfile)
{
++maincounter;
string username;
getline(workingfile, username);
int password;
workingfile >> password;
getline(workingfile, temp);
int friendbasesize = -1;
int friendcounter = -1;
workingfile >> friendbasesize;
getline(workingfile, temp);
string *friendsbase = new string[friendbasesize];
getline(workingfile, temp);
while (temp.compare("Work:") && !temp.empty() && workingfile)
{
++friendcounter;
friendsbase[friendcounter] = temp;
getline(workingfile, temp);
}
string work; int salary = -1;
if (!temp.compare("Work:"))
{
getline(workingfile, temp);
work = temp;
workingfile >> salary;
base[maincounter] = new ChatAdmin(work, salary, username, password, friendsbase, friendbasesize);
getline(workingfile, temp); getline(workingfile, temp);
}
else
{
base[maincounter] = new ChatUser(username, password, friendsbase, friendbasesize);
}
if (workingfile) { getline(workingfile, temp); }// getline(workingfile, temp);
}
ChatClient MyClient(name, year, base, basesize);
cout << MyClient;
system("pause");
workingfile.close();
return 0;
}