-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Expand file tree
/
Copy pathSplitwiseSystem.hpp
More file actions
50 lines (41 loc) · 1.45 KB
/
Copy pathSplitwiseSystem.hpp
File metadata and controls
50 lines (41 loc) · 1.45 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
#ifndef SPLITWISE_SYSTEM_HPP
#define SPLITWISE_SYSTEM_HPP
#include <vector>
#include <string>
#include "User.hpp"
#include "Expense.hpp"
class SplitwiseSystem {
private:
std::vector<User*> users;
std::vector<Expense*> expenses;
int userIdCounter;
int expenseIdCounter;
public:
SplitwiseSystem();
~SplitwiseSystem();
// User management
User* registerUser(const std::string& name, const std::string& email);
void removeUser(const std::string& userId);
// Expense management
Expense* addExpense(const std::string& description, double amount,
const std::string& paidBy,
const std::vector<std::string>& participants,
ExpenseType type = ExpenseType::EQUAL);
bool setExpenseShares(const std::string& expenseId,
const std::map<std::string, double>& shares);
// Balance management
void settleExpense(const std::string& expenseId);
void showBalance(const std::string& userId) const;
void showAllBalances() const;
// Display functions
void displayUsers() const;
void displayExpenses() const;
void displayUserExpenses(const std::string& userId) const;
private:
User* findUser(const std::string& userId) const;
Expense* findExpense(const std::string& expenseId) const;
void updateBalances(Expense* expense);
std::string generateUserId();
std::string generateExpenseId();
};
#endif