// File: exercise5.cpp
// More complex class example

#include <iostream>
#include <vector>
using namespace std;

// Define a class representing a Bank Account
class BankAccount {
private:
    string owner;
    double balance;
    vector<string> transactions;

public:
    // Constructor
    BankAccount(string name, double initialBalance) {
        owner = name;
        balance = initialBalance;
        transactions.push_back("Account opened with balance: " + to_string(initialBalance));
    }

    // Method to deposit money
    void deposit(double amount) {
        balance += amount;
        transactions.push_back("Deposited: " + to_string(amount));
    }

    // Method to withdraw money
    bool withdraw(double amount) {
        if (amount > balance) {
            transactions.push_back("Failed withdrawal attempt: " + to_string(amount));
            return false;
        }
        balance -= amount;
        transactions.push_back("Withdrawn: " + to_string(amount));
        return true;
    }

    // Method to print account details
    void printStatement() const {
        cout << "Account owner: " << owner << endl;
        cout << "Current balance: $" << balance << endl;
        cout << "Transaction history:" << endl;
        for (const string& transaction : transactions) {
            cout << " - " << transaction << endl;
        }
    }
};

int main() {
    // Create a bank account object
    BankAccount account("John Doe", 1000.0);
    
    // Perform some transactions
    account.deposit(500);
    account.withdraw(200);
    account.withdraw(1500); // Should fail
    
    // Print account statement
    account.printStatement();
    
    return 0;
}