// @(#)$Id: Money.C,v 1.3 1997/07/30 20:41:00 leavens Exp $

#include "Money.h"

Money::Money(double amt) throw()
  : cents((long int) (100.0 * amt))
{
}

Money::Money(long int cts) throw()
  : cents(cts)
{
}

Money::~Money() throw()
{
}

long int Money::Dollars() const throw()
{
  return (cents / 100);
}

long int Money::Cents() const throw()
{
  return (cents % 100);
}

Money & Money::operator + (const Money & m2) const throw()
{
  // WRONG: this doesn't protect against out of range results
  return *(new Money(cents + m2.cents));
}

Money & Money::operator - (const Money & m2) const throw()
{
  // WRONG: this doesn't protect against out of range results
  return *(new Money(cents - m2.cents));
}

Money & Money::operator * (double factor) const throw()
{
  // WRONG: this doesn't protect against out of range results
  return *(new Money(factor * cents));
}

bool Money::operator == (const Money & m2) const throw()
{
  return cents == m2.cents;
}

bool Money::operator > (const Money & m2) const throw()
{
  return cents > m2.cents;
}

bool Money::operator >= (const Money & m2) const throw()
{
  return cents >= m2.cents;
}

bool Money::operator < (const Money & m2) const throw()
{
  return cents < m2.cents;
}

bool Money::operator <= (const Money & m2) const throw()
{
  return cents <= m2.cents;
}

