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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
#include <iostream>
#include <iomanip>
#include "atm.h"
using namespace std;
ATM::ATM()
{
savings = 0;
checking = 0;
}
ATM::ATM(int inputsavings, int inputchecking)
{
if (inputsavings < 0)
{
savings = 0;
}
else
{
savings = inputsavings;
}
if (inputchecking < 0)
{
checking = 0;
}
else
{
checking = inputchecking;
}
wAmount = 0;
}
void ATM::Deposit(string transaction, string account, int money)
{
if (account == "Savings")
{
savings += money;
}
else if (account == "Checking")
{
checking += money;
}
PrintReceipt(transaction, account, money);
}
void ATM::Withdrawl(string transaction, string account, int money)
{
const int DailyLimit = 300;
if (money > 0 && money < DailyLimit)
{
if (account == "Savings")
{
if (money < savings)
{
wAmount += money;
savings -= money;
}
else
{
cout << "Error, not enough money in savings" << endl;
}
}
else if (account == "Checking")
{
if (money < checking)
{
wAmount += money;
checking -= money;
}
else
{
cout << "Error, not enough money in checking" << endl;
}
}
}
else if (money < 0)
{
cout << "Error, must enter an amount above 0" << endl;
}
else if (money > DailyLimit)
{
cout << "Error, amount exceeds daily limit" << endl;
}
PrintReceipt(transaction, account, money);
}
void ATM::transferTo(string transaction, string account, int money)
{
if (savings > money && checking > money)
{
if (account == "Savings")
{
if (money < savings)
{
savings += money;
checking -= money;
}
else
{
cout << "Error, not enough money in savings" << endl;
}
}
else if (account == "Checking")
{
if (money < checking)
{
savings += money;
checking -= money;
}
else
{
cout << "Error, not enough money in checking" << endl;
}
}
PrintReceipt(transaction, account, money);
}
}
void ATM::PrintReceipt(string transaction, string account, int money)
{
cout << endl;
cout << "There is now $" << savings << " in savings" << endl;
cout << "There is now $" << checking << " in checking" << endl;
}
|