#include #include #include "Savings.h" #include "Checking.h" using namespace std; pint main() { Checking* checking = new Checking(1); checking->setFirstName ("Alice"); checking->setLastName("Meacham"); checking->setAccountBalance (1000.00); checking->setoverdraftProtection(true); checking->display(); delete checking; Savings* savings = new Savings(2); savings->setFirstName("Bob"); savings->setLastName("Ferling"); savings->setAccountBalance(1003.00); savings->setInterestRate(5.00); savings->display(); return 0; 1 2 3 4 5 HNM COOO #include #include #include #include "Account.h" using namespace std; Account::Account(int accountNumber) { firstName = lastName = ". "; accountBalance = 0; this->account Number = account Number; 6 7 8 9 10 11 12 evoid Account::deposit(double amount){ accountBalance += amount; Ovoid Account::withdraw(double amount){ accountBalance -= amount; 1 W NPO 3a avoid Account::display(){ cout << "Balance: " « setprecision(2) « accountBalance << endl; cout << "Account: " « account Number << endl; cout << "First Name: " « firstName << endl; cout << "Last Name: " « lastName << endl; void Account::setAccount Number(int accountNumber){ this->accountNumber = accountNumber; 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 avoid Account::setAccountBalance (double accountBalance) { this->accountBalance = accountBalance; avoid Account::setFirstName(string firstName) { this->firstName = firstName; avoid Account::setLastName(string lastName) { this->lastName = lastName; string Account::getFirstName() { return firstName; 899 Ostring Account::getLastName(){ return lastName; 与会员专员后台 41 42 43 44 45 46 } pint Account::getAccountNumber(){ return accountNumber; } double Account::getAccountBalance(){ return accountBalance; 2 3 6 9 L1 UE W NOGUE W N OOOO JOU EWNE #ifndef ACCOUNT_H #define ACCOUNT_H #include using namespace std; class Account{ protected: int account Number; double accountBalance; string firstName; string lastName; public: Account(int accountNumber); void deposit(double amount); void withdraw(double amount); void display(); void setAccount Number(int account Number); void setAccountBalance (double accountBalance); void setFirstName(string firstName); void setLastName(string lastName); int getAccountNumber(); double getAccountBalance(); string getFirstName(); string getLastName(); 14 L5 16 L7 18 19 21 22 23 24 25 #endif 1 2 3 4 5 6 7 8 #include #include #include #include "Checking.h" using namespace std; Checking:: Checking(int accountNumber) : Account(accountNumber){ overdraftProtection = false; ноооо зол во мноооо оол EN NE 13 14 avoid Checking::display() { cout << "Balance: " « fixed << setprecision(2) « accountBalance << endl; cout << "Account: " « accountNumber << endl; cout << "First Name: " « firstName << endl; cout << "Last Name: " « lastName << endl; cout < "Overdraft Protection: "« (overdraft Protection ? "true" : "false") << endl << endl; void Checking :: setoverdraftProtection(bool overdraftProtection) { this->overdraftProtection = overdraftProtection; qbool Checking::getoverdraftProtection(){ return overdraft Protection; 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 и Ем оноооо ч ол Еw NE #ifndef CHECKING_H #define CHECKING_H #include #include "Account.h" using namespace std; class Checking : public Account{ private: bool overdraftProtection; public: Checking(int account Number); void display(); void setoverdraftProtection(bool overdraftProtection); bool getoverdraftProtection(); | }; #endif 1 2 3 Ц 5 HNMOOOH #include #include #include #include "Savings.h" using namespace std; Savings::Savings(int account Number) : Account(accountNumber) { this->interestRate = 0.0; 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 avoid Savings::display(){ cout << "Balance: " « fixed << setprecision(2) « accountBalance << endl; cout << "Account: " « accountNumber << endl; cout << "First Name: " « firstName << endl; cout << "Last Name: " « lastName << endl; cout << "Interest Rate: " « fixed << setprecision(2) « interestRate << endl << endl; Avoid Savings::setInterestRate(double interestRate) { this->interestRate = interestRate; çdouble Savings::getInterestRate(){ return interestRate; 0 VOU EWNE Q#ifndef SAVINGS_H #define SAVINGS_H #include #include "Account.h" ſusing namespace std; class Savings : public Account{ private: double interestRate; public: Savings(int accountNumber); Savings(); void deposit(double amount); void withdraw(double amount); void display(); void setInterestRate(double interestRate); double getInterestRate(); 10 11 12 13 14 15 16 17 18 #endif