diff --git a/Driver.cpp b/Driver.cpp new file mode 100644 index 0000000..cc95579 --- /dev/null +++ b/Driver.cpp @@ -0,0 +1,215 @@ +#include +#include +using namespace std; + + +vector tokenize(string input) +{ + vector tokens; + string temp=""; + for(int j=0;juserId=userId; + this->name=name; + this->email=email; + this->mobile_no=mobile_no; + } +}; + + +class SplitwiseController +{ +public: + vector user_list; + vector > balance_sheet; + int user_count; + int max_users; + SplitwiseController() + { + max_users=100; + user_count=0; + + User u(0,"none","none",0); + vector t1(max_users+1,u); + user_list=t1; + + vector > t2; + t2.assign(max_users+1,vector(max_users+1,0)); + balance_sheet=t2; + } + void AddUser(int userId, string name, string email,int mobile_no) + { + User u(userId, name, email, mobile_no); + user_count++; + user_list[user_count]=u; + } + void FunctionCall(int n) + { + string input; + getline(cin,input); + for(int i=0;i>input; + //cout<<"INPUT LINE--"< tokens; + tokens=tokenize(input); + //cout< owing_users_id(no_of_users); + int k; + for(k=4;k<=4+no_of_users-1;k++) + { + owing_users_id[k-4]=stoi(tokens[k].substr(1,tokens[k].size()-1)); + //cout< owing_users_value(no_of_users); + if(tokens[k].compare("EQUAL")==0) + { + int index=0; + //vector owing_users_value(no_of_users); + for(int index=0;index owing_users_value(no_of_users); + for(;k owing_users_id,vector owing_users_value) + { + for(int i=0;i0) + { + flag=true; + cout<>n; + sc.FunctionCall(n); + return 0; +} + diff --git a/input.txt b/input.txt new file mode 100644 index 0000000..50b501b --- /dev/null +++ b/input.txt @@ -0,0 +1,14 @@ +13 +SHOW +SHOW u1 +EXPENSE u1 1000 4 u1 u2 u3 u4 EQUAL +SHOW u4 +SHOW u1 +EXPENSE u1 1250 2 u2 u3 EXACT 370 880 +SHOW +EXPENSE u4 1200 4 u1 u2 u3 u4 PERCENT 40 20 20 20 +SHOW u1 +SHOW +EXPENSE u3 1600 4 u1 u2 u3 u4 EQUAL +EXPENSE u2 2000 4 u1 u2 u3 u4 PERCENT 30 25 25 20 +SHOW \ No newline at end of file diff --git a/test b/test new file mode 100755 index 0000000..1dfb1c1 Binary files /dev/null and b/test differ