//
CALL FUNCTIONS - IF POSSIBLE
//
AVOID WORK VARIABLES - IF POSSIBLE
//
CHAIN FUNCTIONS - IF POSSIBLE
//
//
You CANNOT write any helper functions of your own
you can only use the functions given in the class definition
#include
using namespace::std;
class coin {
friend ostream & operator << ( ostream &, const coin &);
friend bool operator == ( int n, const coin & right);
// will return true if n is equal to the count field of
right
public:
coin(void);
coin(int ct, const char * d);
coin(const coin &);
~coin(void);
int getCount(void) const;
coin & setCount(int n);
coin & setDesc( const char *);
the paramater
const coin & getLarger( const coin & ) const;
// will return as an alias the larger coin
//
, i.e. larger of the invoking instance and
//
use getCount() to determine the largest
const coin & operator = ( const coin &);
coin
operator + ( const coin & ) const;
// return coin with counts added
// same desc as the invoking instance
bool operator == ( const coin &) const;
// return true if the counts are equal
bool operator == ( int v) const;
// return true if v is equal to the count field
private:
const char * getDesc(void) const;
int count;
char desc[25];
};
class bank {
friend
ostream & operator<<(ostream &, const bank &);
public:
bank(void);
bank(int, const char * coinDesc, const char * ownerName);
bank(const bank &);
bank( const coin &, const char * ownerName);
~bank();
int getCount(void) const;
bank &
changeOwner( const char *);
const bank & operator = (const bank &);
bool
};
//
operator == ( const bank & ) const;
// will return true if the owners are equal as strings
//
and coin fields data are equal as coins
bool operator != ( const bank &) const;
private:
coin data;
char * owner;
Write the Class functions
ostream & operator << ( ostream & w, const coin & c)
{
}
bool operator == ( int n, const coin & right)
// will return true if n is equal to the count field of
right
{
}
coin::coin(void)
{
}
coin::coin(int ct, const char * d)
{
}
coin::coin(const coin & other)
{
}
coin::~coin(void)
{
}
int coin::getCount(void) const
{
}
const char * coin::getDesc(void) const
{
}
coin & coin::setCount(int count)
{
}
//
coin & coin::setDesc( const char * c)
{
MUST USE THE PARAMETER NAME OF COUNT
}
const coin & coin::getLarger( const coin & right ) const
{
}
//
In the above function, explain the 3 uses of const
const coin & coin::operator = ( const coin & right)
{
}
coin
{
coin::operator + ( const coin & right) const
//
// return coin with counts added
same desc as the invoking instance
}
bool coin::operator == ( const coin & right) const
// return true if the counts are equal
{
}
bool coin::operator == ( int v) const
// return true if v is equal to the count field
{
}
//
******
bank functions
*******
ostream & operator<<(ostream & w, const bank & b)
{
}
bank::bank(void)
{
}
bank::bank(int a, const char * coinDesc,
{
}
bank::bank(const bank & other)
{
const char * ownerName)
}
bank::bank( const coin & c, const char * ownerName)
{
}
bank::~bank()
{
}
int bank::getCount(void) const
{
}
bank &
{
bank::changeOwner( const char * c)
}
const bank & bank::operator = (const bank & right)
{
}
bool bank::operator == ( const bank & right ) const
{
// will return true if the owners are equal as strings
//
and the coin fields are equal as coins
}
bool
{
bank::operator != ( const bank & right ) const
}
// *****************************************************************************
//
Client functions
coin returnLarger( const coin & left, const coin & right)
// will return the larger coin, based on the count value
// the desc of the coin returned will be "Larger Coin";
{
// write returnLarger now
}
void main()
{
coin a(4,"Dime");
coin c(5,"Penny"), d(12,"Quarter"), e(15,"$20 Gold Coin"), f;
bank b(24,"Dollar Bill", "John Doe");
cout << a << b << c;
// Write the above using function notation:
//
________________________________________________________
f = (c + d) + e;
//
Write the above using function notation NOTE: There are 3 operators:
}
//
__________________________________________________________
return;