-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
803 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
124 changes: 124 additions & 0 deletions
124
LowLevelDesign/SplitwiseApplication/.idea/uiDesigner.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Design a system that allows for the addition of expenses and split the sam among multiple users or within a group. | ||
|
||
Mandatory Requirements: | ||
|
||
Create a group. A group can contain two or more users. | ||
Split expenses between users( they may not be a part of a group) or in a group. | ||
The strategy of splitting the amount should be extensible. You can implement equal splitting. | ||
Able to see the pending credit or pending debit in a group or between users. (Let's say between A and B who is going to pay which user and the amount) | ||
Can view the transaction details ( All the expenses which got added) in a group or peer-to-peer. | ||
Bonus points: | ||
|
||
Simplify debts ( Let’s say A has to pay 30 to B, B has to pay 30 to C, then in simplify debt view, A has to pay 30 to C directly instead of B ). | ||
|
||
Guidelines: | ||
|
||
Use any IDE | ||
Write a driver class for demo purposes. Which will execute all the commands in one place in the code and have test cases. | ||
You can print the output in the console. Do not create any UI for the application. | ||
Please prioritize code compilation, execution, and completion | ||
Work on the expected output first and then add bonus features last. | ||
Expectations: | ||
|
||
Your code should cover all the mandatory functionalities explained above. | ||
Your code should be executable and clean. | ||
Your code should be properly refactored, and exceptions should be gracefully handled. | ||
Please add any assumptions taken in a README file. | ||
How will you be evaluated? | ||
|
||
Code should be working. | ||
Code readability and testability | ||
Separation Of Concerns | ||
Object-Oriented concepts. | ||
Language proficiency. | ||
Scalability | ||
Test Coverage | ||
Concurrency handling(Bonus Points) |
11 changes: 11 additions & 0 deletions
11
LowLevelDesign/SplitwiseApplication/SplitwiseApplication.iml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
Binary file added
BIN
+2.63 KB
LowLevelDesign/SplitwiseApplication/out/production/SplitwiseApplication/Driver.class
Binary file not shown.
Binary file added
BIN
+8.7 KB
...plitwiseApplication/out/production/SplitwiseApplication/dao/SplitWiseBalanceManager.class
Binary file not shown.
Binary file added
BIN
+1.65 KB
...Design/SplitwiseApplication/out/production/SplitwiseApplication/model/account/Group.class
Binary file not shown.
Binary file added
BIN
+1001 Bytes
...lDesign/SplitwiseApplication/out/production/SplitwiseApplication/model/account/User.class
Binary file not shown.
Binary file added
BIN
+908 Bytes
...SplitwiseApplication/out/production/SplitwiseApplication/model/expense/EqualExpense.class
Binary file not shown.
Binary file added
BIN
+1.92 KB
...sign/SplitwiseApplication/out/production/SplitwiseApplication/model/expense/Expense.class
Binary file not shown.
Binary file added
BIN
+917 Bytes
.../SplitwiseApplication/out/production/SplitwiseApplication/model/expense/ExpenseType.class
Binary file not shown.
Binary file added
BIN
+345 Bytes
...ign/SplitwiseApplication/out/production/SplitwiseApplication/model/split/EqualSplit.class
Binary file not shown.
Binary file added
BIN
+1.29 KB
...elDesign/SplitwiseApplication/out/production/SplitwiseApplication/model/split/Split.class
Binary file not shown.
Binary file added
BIN
+647 Bytes
...n/SplitwiseApplication/out/production/SplitwiseApplication/service/ExpenseService$1.class
Binary file not shown.
Binary file added
BIN
+1.93 KB
...ign/SplitwiseApplication/out/production/SplitwiseApplication/service/ExpenseService.class
Binary file not shown.
Binary file added
BIN
+924 Bytes
...esign/SplitwiseApplication/out/production/SplitwiseApplication/service/GroupService.class
Binary file not shown.
Binary file added
BIN
+3.59 KB
...n/SplitwiseApplication/out/production/SplitwiseApplication/service/SplitWiseService.class
Binary file not shown.
Binary file added
BIN
+706 Bytes
...Design/SplitwiseApplication/out/production/SplitwiseApplication/service/UserService.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import dao.SplitWiseBalanceManager; | ||
import model.account.Group; | ||
import model.account.User; | ||
import model.expense.ExpenseType; | ||
import model.split.EqualSplit; | ||
import model.split.Split; | ||
import service.GroupService; | ||
import service.SplitWiseService; | ||
import service.UserService; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Driver { | ||
public static void main(String[] args) { | ||
System.out.println("SplitWise Application!!!"); | ||
|
||
SplitWiseBalanceManager splitWiseBalanceManager = SplitWiseBalanceManager.getSplitWiseBalanceManagerInstance(); | ||
UserService userService = new UserService(splitWiseBalanceManager); | ||
GroupService groupService = new GroupService(splitWiseBalanceManager); | ||
SplitWiseService splitWiseService = new SplitWiseService(splitWiseBalanceManager); | ||
|
||
//create users | ||
User user1 = userService.addUser("Mandeep"); | ||
User user2 = userService.addUser("Sandeep"); | ||
User user3 = userService.addUser("Bob"); | ||
User user4 = userService.addUser("Alice"); | ||
|
||
|
||
//Create Expense 1 | ||
Split split1 = new EqualSplit(user1); | ||
Split split2 = new EqualSplit(user2); | ||
Split split3 = new EqualSplit(user3); | ||
List<Split> splitListForExpense1 = new ArrayList<>(List.of(split1, split2, split3)); | ||
splitWiseService.addExpense(ExpenseType.EQUAL, 900, "Mandeep", | ||
splitListForExpense1, "Expense Number 1", | ||
List.of("Mandeep", "Sandeep","Bob")); | ||
|
||
//Display balance for users | ||
splitWiseService.showUserExpenses("Mandeep"); | ||
splitWiseService.showUserExpenses("Alice"); | ||
splitWiseService.showUserExpenses("Bob"); | ||
|
||
//group Expense | ||
|
||
//create group | ||
Group group1 = groupService.addGroup("MyTestGroup", List.of("Mandeep","Bob"), | ||
"This group is created for testing"); | ||
|
||
splitWiseService.addExpense(ExpenseType.EQUAL, 900, "Mandeep", | ||
splitListForExpense1, "Expense Number 1", | ||
List.of("Mandeep", "Sandeep","Bob"), "MyTestGroup"); | ||
|
||
//Get Group Expense | ||
splitWiseService.showGroupExpense("MyTestGroup"); | ||
|
||
|
||
//List all expenses | ||
splitWiseService.showAllExpenses(); | ||
|
||
} | ||
} |
Oops, something went wrong.