Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Friends
dsac::design::CreditCard Class Reference

#include <credit_card.h>

Inheritance diagram for dsac::design::CreditCard:
Inheritance graph
Collaboration diagram for dsac::design::CreditCard:
Collaboration graph

Public Member Functions

 CreditCard (std::string cust, std::string bk, std::string acnt, int lim, double initial_bal=0.0)
 Constructs a new credit card. The initial balance is 0.0 by default.
 
std::string get_customer () const
 return the customer's name
 
std::string get_bank () const
 return the bank's name
 
std::string get_account () const
 return the account number as a string
 
int get_limit () const
 return the credit limit (measured in dollars)
 
double get_balance () const
 return the current balance (measured in dollars)
 
bool charge (double price)
 
void make_payment (double amount)
 Processes customer payment to reduce the balance.
 

Protected Attributes

double balance
 

Friends

std::ostream & operator<< (std::ostream &out, const CreditCard &c)
 

Constructor & Destructor Documentation

◆ CreditCard()

dsac::design::CreditCard::CreditCard ( std::string  cust,
std::string  bk,
std::string  acnt,
int  lim,
double  initial_bal = 0.0 
)
inline

Constructs a new credit card. The initial balance is 0.0 by default.

Member Function Documentation

◆ charge()

bool dsac::design::CreditCard::charge ( double  price)
inline

Charges the give price to the card, assuming sufficient credit limit.

Parameters
pricethe amount to be charged
Returns
true if charge was accepted; false if charge was denied

◆ get_account()

std::string dsac::design::CreditCard::get_account ( ) const
inline

return the account number as a string

◆ get_balance()

double dsac::design::CreditCard::get_balance ( ) const
inline

return the current balance (measured in dollars)

◆ get_bank()

std::string dsac::design::CreditCard::get_bank ( ) const
inline

return the bank's name

◆ get_customer()

std::string dsac::design::CreditCard::get_customer ( ) const
inline

return the customer's name

◆ get_limit()

int dsac::design::CreditCard::get_limit ( ) const
inline

return the credit limit (measured in dollars)

◆ make_payment()

void dsac::design::CreditCard::make_payment ( double  amount)
inline

Processes customer payment to reduce the balance.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const CreditCard c 
)
friend

Field Documentation

◆ balance

double dsac::design::CreditCard::balance
protected

The documentation for this class was generated from the following file: