Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef Banking_Base
- #define Banking_Base
- #include <string>
- using namespace std;
- class BankAccount {
- //Let's create some properties for our Class
- //These guys are private by default
- string cardType, cardOwner, rewardsType, cardNumber;
- double creditLimit, availableCredit, currentBalance;
- public:
- //Let's create some methods for our Class
- //These guys are public, and will allow us to modify the private properties
- //in their same class.
- //These are just prototypes, not the actual code that will be executed upon a call.
- void setCardType (string);
- void setCardOwner(string);
- void setRewardsType(string);
- void setCardNumber(string);
- void setCreditLimit(double);
- bool confirmAction(double); //Unused Method, see line 74
- void newAuthorization(double);
- void printProperty();
- void printProperty(char);
- //Let's bring in the constructors, and overload them!
- BankAccount (string);
- BankAccount (string, string, string);
- }; //End of Class
- //Time for Methods again.
- BankAccount::BankAccount(string c)
- {
- cardNumber = c;
- currentBalance = 0;
- }
- BankAccount::BankAccount(string a, string b, string c)
- {
- cardOwner = a;
- cardType = b;
- cardNumber = c;
- currentBalance = 0;
- }
- void BankAccount::setCardType(string a)
- {
- cardType = a;
- }
- void BankAccount::setCardOwner(string a)
- {
- cardOwner = a;
- }
- void BankAccount::setRewardsType(string a)
- {
- rewardsType = a;
- }
- void BankAccount::setCardNumber(string a)
- {
- cardNumber = a;
- }
- void BankAccount::setCreditLimit(double a) {
- creditLimit = a;
- availableCredit = creditLimit;
- }
- //Unused method, I have to work on it a bit more.
- bool BankAccount::confirmAction(double a) {
- cout << "Your current available balance is: " << availableCredit
- << "\nAre you sure you would like to continue with the purchase?(Y = Yes, N = No)"
- << "\nThe total amount to be deducted is: " << a <<endl;
- char confirm = cin.get();
- if(confirm == 'Y') {
- return confirm;
- }
- else if(confirm == 'N') {
- return false;
- }
- }
- void BankAccount::newAuthorization(double a) {
- cout << "Your current available balance is: " << availableCredit
- << "\nAre you sure you would like to continue with the purchase?(Y = Yes, N = No)"
- << "\nThe total amount to be deducted is: " << a <<endl;
- string confirm;
- cin >> confirm;
- if (confirm == "Y") {
- availableCredit -= a;
- currentBalance += a;
- cout << "The transaction was processed succesfully" << endl;
- cout << "Your new balance is " << availableCredit << endl;
- }
- else {
- cout << "No Transaction was processed today!" << endl;
- }
- }
- void BankAccount::printProperty()
- {
- cout << "This method allows you to explore the properties of an object belonging to the 'BankAccount' class.\n"
- << "What property would you like to access?"
- << "\nEnter 't' for type, 'o' for owner, 'r' for rewards type, 'c' for card number, 'a' for available credit, 'l' for credit limit, 'b' for current balance."
- << endl;
- char propertyToPrint;
- cin >> propertyToPrint;
- switch(propertyToPrint) {
- case 't':
- cout << cardType << '\n' << endl;
- break;
- case 'o':
- cout << cardOwner << '\n' << endl;
- break;
- case 'r':
- cout << rewardsType << '\n' << endl;
- break;
- case 'c':
- cout << cardNumber << '\n' << endl;
- break;
- case 'a':
- cout << availableCredit << '\n' << endl;
- break;
- case 'l':
- cout << creditLimit << '\n' << endl;
- break;
- case 'b':
- cout << currentBalance << '\n' << endl;
- break;
- default:
- cout << "Make sure you enter one of the valid characters!" << endl;
- }
- }
- void BankAccount::printProperty(char propertyToPrint)
- {
- switch(propertyToPrint) {
- case 't':
- cout << cardType << '\n' << endl;
- break;
- case 'o':
- cout << cardOwner << '\n' << endl;
- break;
- case 'r':
- cout << rewardsType << '\n' << endl;
- break;
- case 'c':
- cout << cardNumber << '\n' << endl;
- break;
- case 'a':
- cout << availableCredit << '\n' << endl;
- break;
- case 'l':
- cout << creditLimit << '\n' << endl;
- break;
- case 'b':
- cout << currentBalance << '\n' << endl;
- break;
- default:
- cout << "Make sure you enter one of the valid characters!" << endl;
- }
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement