Ephemeral
An anti-hoarding currency that rewards circulation through natural decay.
Loading...
Searching...
No Matches
Wallet.h
1#pragma once
2#include <ctime>
3#include <cmath>
4#include <string>
5
6namespace Chiffres {
22 class Wallet {
23 public:
34 Wallet(std::string owner, double balance);
35
45 [[nodiscard]] double getBalance() const;
46
59 void deposit(double amount);
60
73 bool withdraw(double amount);
74
75 private:
87 void update_balance_to_now();
88
90 static constexpr double DECAY_RATE = 0.000008;
92 double m_balance;
94 std::string m_owner;
96 time_t m_last_activity_timestamp;
97 };
98}
bool withdraw(double amount)
Attempt to withdraw funds from the wallet.
Definition Wallet.cpp:35
Wallet(std::string owner, double balance)
Construct a wallet with an owner and initial balance.
Definition Wallet.cpp:5
void deposit(double amount)
Deposit funds into the wallet.
Definition Wallet.cpp:30
double getBalance() const
Get the current balance (read-only).
Definition Wallet.cpp:21