-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWallet.h
More file actions
66 lines (52 loc) · 2.05 KB
/
Copy pathWallet.h
File metadata and controls
66 lines (52 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ===========================================================================
// Wallet.h
// ===========================================================================
#pragma once
#include <iostream>
class Wallet
{
friend std::ostream& operator<<(std::ostream& out, const Wallet& Wallet);
private:
unsigned long long m_euros;
unsigned int m_cents;
public:
// c'tors
Wallet();
Wallet(unsigned long long euros, unsigned int cents);
explicit Wallet(unsigned long long euros);
Wallet(std::string euros, std::string cents);
// getter
unsigned long long getEuros() const;
unsigned int getCent() const;
// public interface
void add(unsigned long long euros, unsigned int cents);
void add(unsigned long long euros);
void add(const Wallet& other);
void sub(unsigned long long euros, unsigned int cents);
void sub(unsigned long long euros);
void sub(const Wallet& other);
void print() const;
int compareTo(const Wallet& other) const;
unsigned long long to_cents() const;
std::string to_string() const;
// operators
void operator += (const Wallet&);
void operator += (unsigned long long);
void operator -= (const Wallet&);
void operator -= (unsigned long long);
// increment/decrement operators (prefix/postfix version)
Wallet& operator++ (); // prefix increment
Wallet operator++ (int); // postfix increment
Wallet& operator-- (); // prefix decrement
Wallet operator-- (int); // postfix decrement
// comparison operators
friend bool operator== (const Wallet&, const Wallet&);
friend bool operator!= (const Wallet&, const Wallet&);
friend bool operator< (const Wallet&, const Wallet&);
friend bool operator<= (const Wallet&, const Wallet&);
friend bool operator> (const Wallet&, const Wallet&);
friend bool operator>= (const Wallet&, const Wallet&);
};
// ===========================================================================
// End-of-File
// ===========================================================================