-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.cpp
More file actions
97 lines (89 loc) · 2.3 KB
/
driver.cpp
File metadata and controls
97 lines (89 loc) · 2.3 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
#include "split_service.h"
#include<fstream>
#include <sstream>
int main()
{
SplitService *ser = new SplitService(4);
User *U1 = new User(0, "u1", "Susmita", "sm@com", "11890");
ser->set_user_table("u1", U1);
User *U2 = new User(1, "u2", "Ayan", "ay@com", "11890");
ser->set_user_table("u2", U2);
User *U3 = new User(2, "u3", "Moumita", "mm@com", "11890");
ser->set_user_table("u3", U3);
User *U4 = new User(3, "u4", "Subhayan", "sb@com", "11890");
ser->set_user_table("u4", U4);
fstream input;
input.open("input.txt");
string line;
while (getline(input, line))
{
stringstream s(line);
string c;
s >> c;
if (c == "SHOW")
{
string show_arg;
s >> show_arg;
if (show_arg == "")
{
ser->SHOW_ALL();
}
else
{
ser->SHOW(show_arg, 0);
}
}
else if (c == "EXPENSE")
{
int num = 0;
string payer;
vector <string> users;
string type;
int total;
s >> payer;
s >> total;
s >> num;
for (int i = 0; i < num; i++)
{
string u;
s >> u;
users.push_back(u);
}
s >> type;
if (type == "EQUAL")
{
ser->EXPENSE_EQUAL(total, payer, users);
}
else if (type == "EXACT")
{
vector <int> amounts;
for (int i = 0; i<num; i++)
{
int amount;
s >> amount;
amounts.push_back(amount);
}
ser->EXPENSE_EXACT(total, payer, users, amounts);
}
else if (type == "PERCENT")
{
vector <float> percents;
for (int i = 0; i<num; i++)
{
float percent;
s >> percent;
percents.push_back(percent);
}
ser->EXPENSE_PERCENT(total, payer, users, percents);
}
else
cout << "INVALID TYPE" << endl;
}
else
{
cout << "INVALID OPERTAION " << endl;
}
}
input.close();
return 0;
}