Conversation
| System.out.println("inside equal"); | ||
| splitWiseService.distributeMoneyIfEqual(borrowerList,lender,amount); | ||
| } | ||
| else if(Expensetype.equals("PERCENT")) |
There was a problem hiding this comment.
You can use switch case for better readability of code.
| int amount=Integer.parseInt(inputarray[2]); | ||
| int noOfborrowers=Integer.parseInt(inputarray[3]); | ||
| ArrayList<String> borrowerList=new ArrayList<String>(); | ||
| int i=4; |
| else if(Expensetype.equals("PERCENT")) | ||
| { | ||
| ArrayList<Integer> percentList=new ArrayList<>(); | ||
| int m=i+2; |
| import com.workattech.sw.models.Money; | ||
| import com.workattech.sw.models.User; | ||
|
|
||
| public class PrintService { |
|
|
||
| public class PrintService { | ||
|
|
||
| Map<String,ArrayList<Money>> listOfUserWhoOwesToUser; |
| public class PrintService { | ||
|
|
||
| Map<String,ArrayList<Money>> listOfUserWhoOwesToUser; | ||
| public void printMoneyOwnedByParticularUser(String user,SplitWiseService splitWiseService) |
There was a problem hiding this comment.
This method is not very readable
| ArrayList<User> userList=new ArrayList<User>(); | ||
| CalculateExpense calculateExpense=new CalculateExpense(); | ||
| public Map<String,ArrayList<Money>> listOfUserWhoOwesToUser=new HashMap<>(); | ||
| public Map<String,ArrayList<Money>> getlistOfUserWhoOwesToUser() |
There was a problem hiding this comment.
should use proper camelCase
| public void distributeMoneyIfEqual(ArrayList<String> borrowers,String lender,int amount) | ||
| { | ||
|
|
||
| double amountToBeDistributed=calculateExpense.CalculateMoneyEqual(amount,borrowers.size()+1); |
There was a problem hiding this comment.
CalculateMoneyEqual?
Should be calculateMoneyEqual
There was a problem hiding this comment.
same comment for other methods
| subtractMoneyFromBorrowers(borrowers.get(i),lender,amountToBeDistributed); | ||
| } | ||
| } | ||
| public void distributeMoneyIfExact(ArrayList<String> borrowers,String lender,ArrayList<Integer> exactShare) |
There was a problem hiding this comment.
instead of exposing multiple methods from here. You could have created a single method like addExpense and taken an expense object as param. And deciding which distribution to choose could be done here
| double amount; | ||
| public Money(String moneyGivenBy,String moneyTakenBy,double amount) | ||
| { | ||
| this.personA=moneyGivenBy; |
There was a problem hiding this comment.
Money should not know about who paid to whom. A better name would have been expense
| this.amount-=amountTakenBypersonA; | ||
| if(this.amount<0) | ||
| { | ||
| this.amount=0; //No money is owned by personA from personB |
|
@dharani1997 sorry for the delay! Was busy at work. Gave a few comments. Please check. |
No description provided.