#ifndef CREDIT_CARD_H // avoid repeated expansion #define CREDIT_CARD_H #include // provides string #include // provides ostream #include "Money.h" /** Represents a credit card record with a monthly billing cycle */ class CreditCard { public: /** Construct a new credit card. * * @param no the credit card number (expressed as a string) * @param nm the card-holder's name * @param lim maximum dollar limit for card * @param rt A fraction which represents the monthly interest rate * @param bal Initial balance for this account */ CreditCard(std::string no, std::string nm, Money lim, double rt, Money bal=Money()); ////////////////////////////////////// // accessors functions ////////////////////////////////////// /** Return the card number. * @return string representing the card number */ std::string getNumber() const; /** Return the name of the card holder. * @return person's name as a string */ std::string getName() const; /** Return the credit limit. * @return limit expressed in dollars. */ Money getLimit() const; /** Return the interest rate. * @return monthly interest rate (e.g. 0.0079 for 0.79% monthly rate) */ double getRate() const; /** Return the up-to-the-minute balance. * @return up-to-the-minute balance, in dollars (or fraction theoreof). */ Money getCurrentBalance() const; /** Return the account balance which was reported as of the end of the previous month. * @return balance as was calculated at end of previous month */ Money getPreviousBalance() const; /** Return the minimum payment ammount that was reported at the end of the previous month. * @return minimum payment that was requested at end of previous month */ Money getMinPayment() const; ////////////////////////////////////// // update functions ////////////////////////////////////// /** Attempts to make a charge of given price against this card. * * A charge should be disallowed if it would cause the credit limit * to be exceeded. * * All negative charges should be disallowed * (instead, they should be processed by making a payment) * * @return true if charge was allowed; false if disallowed */ bool chargeIt(Money price); /** Used to make a payment on behalf of the account holder. * * Negative payments should be ignored. * * A positive payment is used to pay off a portion of the current * balance. (if user pays off more than their current balance, the * excess should still be credited in the form of a negative * balance.) */ void makePayment(Money payment); /** This method is called to signify the end of a billing month. * It is used to assess any fees or interest which are incurred and * to record a new minimum payment required for the coming month. * * return the new minimum payment required */ Money endOfMonth(); private: // private member data // ADD WHATEVER MEMBERS YOU WISH TO SUPPORT THE CLASS }; // print card information std::ostream& operator<<(std::ostream& out, const CreditCard& c); #endif