2026-08-11 17:40:36 +03:00
|
|
|
#include "classes_and_objects.hpp"
|
|
|
|
|
|
|
|
|
|
namespace oop {
|
|
|
|
|
|
2026-08-15 17:43:30 +03:00
|
|
|
BankAccount::BankAccount(std::string owner, const double balance)
|
2026-08-11 17:40:36 +03:00
|
|
|
: owner_(std::move(owner)), balance_(balance) {}
|
|
|
|
|
|
|
|
|
|
auto BankAccount::owner() const -> const std::string& { return owner_; }
|
|
|
|
|
auto BankAccount::balance() const -> double { return balance_; }
|
|
|
|
|
|
2026-08-15 17:43:30 +03:00
|
|
|
void BankAccount::deposit(const double amount)
|
|
|
|
|
{
|
|
|
|
|
this->balance_ += amount;
|
2026-08-11 17:40:36 +03:00
|
|
|
}
|
|
|
|
|
|
2026-08-15 17:43:30 +03:00
|
|
|
auto BankAccount::withdraw(const double amount) -> bool
|
|
|
|
|
{
|
|
|
|
|
if (this->balance_ >= amount) {
|
|
|
|
|
this->balance_ -= amount;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2026-08-11 17:40:36 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace oop
|