Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #ifndef TST_TESTACCOUNT_H
  2. #define TST_TESTACCOUNT_H
  3.  
  4. #include <gtest/gtest.h>
  5. #include <gmock/gmock-matchers.h>
  6.  
  7. using namespace testing;
  8.  
  9. struct BankAccount
  10. {
  11. int balance = 0;
  12. int deposits = 0;
  13. int overdraws = 0;
  14. int withdrawals = 0;
  15.  
  16. BankAccount(){}
  17. explicit BankAccount(const int balance)
  18. :balance{balance}
  19. {}
  20. void deposit (int amount)
  21. {
  22. balance += amount;
  23. deposits++;
  24. }
  25. void overdraw (int amount)
  26. {
  27. balance -= amount;
  28. overdraws++;
  29. }
  30. bool withdraw (int amount)
  31. {
  32. if (amount <= balance){
  33. balance-=amount;
  34. return true;
  35. }return false;
  36. withdrawals++;
  37. }
  38. bool depositParam (int amount)
  39. {
  40. if (amount <= balance){
  41. balance+=amount;
  42. return true;
  43. }return false;
  44. deposits++;
  45. }
  46. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement