Personal Finance 1.0.0
An application that allows you to track/store/view finances, as well as calculate different financial values.
Money.h
Go to the documentation of this file.
1/*
2 * Author: Dawson Dauphinais
3 * ddauphin@nmu.edu
4 *
5 * Date Last Modified: 11/23/2021
6 *
7 * */
8
9#ifndef PERSONALFINANCE_MONEY_H
10#define PERSONALFINANCE_MONEY_H
11
12#include <iostream>
13#include <cmath>
14#include <string>
15// #include <algorithm>
16
17using namespace std;
18
26class Money
27{
28public:
31
37 explicit Money(double m);
38
44 Money(int d, int c);
45
52 explicit Money(const string &s);
53
60
67 Money operator+(const Money &m) const;
68
75 Money operator-(const Money &m) const;
76
84 Money operator*(double val) const;
85
93 Money operator/(double m) const;
94
103
111 static Money power(Money &m, int exp);
112
120 static double power(double d, int exp);
121
128 bool operator==(const Money &m) const;
129
137 friend ostream &operator<<(ostream &out, const Money &m);
138
145 static double toDouble(const Money &m);
146
152 static string toString(const Money &m1);
153
154private:
155 int dollars{};
156 int cents{};
157};
158
159#endif //PERSONALFINANCE_MONEY_H
The Money class is used to allow operations on Money.
Definition: Money.h:27
Money(double m)
Constructor for the Money class based on a double.
bool operator==(const Money &m) const
Overloads the == operator for the Money class.
friend ostream & operator<<(ostream &out, const Money &m)
Overloads the << operator for the Money class.
static string toString(const Money &m1)
Converts a Money object to a string.
Money(int d, int c)
Constructor for the Money class based on two integers.
Money operator+(const Money &m) const
Overloads the + operator for the Money class.
static Money power(Money &m, int exp)
Implements the power function for the Money class.
Money operator*(double val) const
Overloads the * operator for the Money class.
Money()
Default constructor for the Money class.
static double toDouble(const Money &m)
Converts a Money object to a double value.
Money operator-() const
Overloads the - operator for the Money class.
Money operator/(double m) const
Overloads the / operator for the Money class.
static double power(double d, int exp)
Helper function for the power function of the Money class.
Money(const string &s)
Constructor for the Money class based on a string.
Money operator/(Money &m) const
Overloads the / operator for the Money class.
Money operator-(const Money &m) const
Overloads the - operator for the Money class.