include #include #include #include "bank.h" int main() { // =================== YOUR CODE HERE =================== // 1. Create a Bank object, name it anything you'd like :) // ======================================================= // =================== YOUR CODE HERE =================== // 2. Create 3 new accounts in your bank. // * The 1st account should belong to "Tuff
C++
main.cc file
#include <iostream>
#include <map>
#include <vector>
#include "bank.h"
int main() {
// =================== YOUR CODE HERE ===================
// 1. Create a Bank object, name it anything you'd like :)
// =======================================================
// =================== YOUR CODE HERE ===================
// 2. Create 3 new accounts in your bank.
// * The 1st account should belong to "Tuffy", with
// a balance of $121.00
// * The 2nd account should belong to "Frank", with
// a balance of $1234.56
// * The 3nd account should belong to "Oreo", with
// a balance of $140.12
// =======================================================
// =================== YOUR CODE HERE ===================
// 3. Deactivate Tuffy's account.
// =======================================================
// =================== YOUR CODE HERE ===================
// 4. Call DisplayBalances to print out all *active*
// account balances.
// =======================================================
}
bank.h file
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include "account.h"
class Bank {
public:
// ======================= YOUR CODE HERE =======================
// Write the Bank class here. Refer to the README for the member
// variables, constructors, and member functions needed.
//
// Note: mark functions that do not modify the member variables
// as const, by writing `const` after the parameter list.
// Pass objects by const reference when appropriate.
// Remember that std::string is an object!
// ===============================================================
private:
// We provided this helper function to you to randomly generate
// a new Bank Account ID to be used in CreateAccount.
int GenerateAccountId() const {
return std::rand() % 9000 + 1000; // [1000, 9999]
}
};
bank.cc file
#include "bank.h"
// ========================= YOUR CODE HERE =========================
// This implementation file (bank.cc) is where you should implement
// the member functions declared in the header (bank.h), only
// if you didn't implement them inline within bank.h.
//
// Remember to specify the name of the class with :: in this format:
// <return type> MyClassName::MyFunction() {
// ...
// }
// to tell the compiler that each function belongs to the Bank class.
// ===================================================================
account.h file
#include <string>
class Account {
public:
Account(const std::string& name, double balance)
: account_holder_(name), balance_(balance) {}
const std::string& GetAccountHolder() const {
return account_holder_;
}
double GetBalance() const {
return balance_;
}
private:
std::string account_holder_;
double balance_;
};
Sample Output:
Frank: $1234.56
Oreo: $140.12
Trending now
This is a popular solution!
Step by step
Solved in 3 steps