Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class BankAccount {
- private: // Accessible only to members
- string accID;
- double accBalance;
- string accName;
- double interest;
- public: // Accesible to everyone
- BankAccount()
- : accID("00000-00000"), accName(""), accBalance(0), interest(0) {}
- BankAccount(string accID_in, string accName_in, double accBalance_in, double interest_in)
- : accID(accID_in), accName(accName_in), accBalance(accBalance_in), interest(interest_in) {}
- string GetID() {
- return accID;
- }
- string GetName() {
- return accName;
- }
- double GetBalance() {
- return accBalance;
- }
- double GetInterest() {
- return interest;
- }
- void IncreaseBalance(int balance) {
- accBalance += balance;
- }
- void DecreaseBalance(int balance) {
- accBalance -= balance;
- }
- void addDailyInterest() {
- accBalance = accBalance + (accBalance * interest);
- }
- void Deactivated(string ID) {
- accID = "0000-0000";
- accBalance = 0;
- accName = "";
- }
- bool isActive() {
- if (accID == "00000-00000" && accName == "") { // Do checks here
- return false; // Return true or false based on checks
- }
- else {
- return true;
- }
- }
- void SetHolderName(string newName) {
- accName = newName;
- }
- void print() {
- cout << "Account ID is: " << accID << endl;
- cout << "Account balance is: " << accBalance << endl;
- cout << "Account name is: " << accName << endl;
- cout << "Daily interest is: " << interest << endl;
- }
- };
- int main()
- {
- BankAccount b1;
- if (b1.isActive() == true) {
- cout << "Your account is active" << endl;
- }
- else {
- cout << "Your account is deactivated" << endl;
- }
- cout << "Account ID is: " << b1.GetID() << endl;
- cout << "Account balance is: " << b1.GetBalance() << endl;
- cout << "Account name is: " << b1.GetName() << endl;
- cout << "Daily interest is: " << b1.GetInterest() << endl << endl;
- BankAccount b2("12345-67890", "Brandon", 1000, .7);
- if (b2.isActive() == true) {
- cout << "Your account is active" << endl;
- }
- else {
- cout << "Your account is deactivated" << endl;
- }
- b2.SetHolderName("Ryan");
- b2.print();
- b2.addDailyInterest();
- b2.IncreaseBalance(500);
- // New balance
- cout << "New balance is: " << b2.GetBalance() << endl;
- // New balance
- b2.DecreaseBalance(750);
- cout << "New balance is: " << b2.GetBalance() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement