Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public double GetBalance(string name) {
  2.  
  3. double balance = 0;
  4. double spending = 0;
  5. double income = 0;
  6.  
  7. foreach (Block block in Blocks)
  8. {
  9. var transactions = block.Transactions;
  10.  
  11. foreach (Transaction transaction in transactions)
  12. {
  13.  
  14. var sender = transaction.Sender;
  15. var recipient = transaction.Recipient;
  16.  
  17. if (name.ToLower().Equals(sender.ToLower())) {
  18. spending += transaction.Amount + transaction.Fee;
  19. }
  20.  
  21.  
  22. if (name.ToLower().Equals(recipient.ToLower())) {
  23. income += transaction.Amount;
  24. }
  25.  
  26. balance = income - spending;
  27. }
  28. }
  29. return balance;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement