The Treasury Department is very pleased with your work. At the request of the cashier industry, the Treasury Department has asked you to extend your previous work by programming common operations on Coins. So, they gave you the following extended design:
class Coin
{
public:
Coin();
Coin(const string &newFace, double newValue);
bool isHeads() const; /* accessor for the heads variable */
string getFace() const;
double getValue() const;
void print() const;
void setFace(const string &newFace);
void setValue(double newValue);
Coin operator+(const Coin &rightCoin); /* argument is the Coin on the right hand side */
Coin operator-(const Coin &rightCoin); /* argument is the Coin on the right hand side */
void operator!(); /* this should flip the coin once */
private:
bool heads; /* new variable */
string face;
double value;
};
For Part I, start with your lab 10 and add the following functionality:
If you were absent for or didn't do well on lab 10, you can use my model solution to build on instead.
Take your Part I and implement the ! operator. All this should do is randomly assign either true or false to isHeads. The American Society Of Coin Flippers (ASOCF) reminds you that in order to get a statistically normal distribution, you need at least 20 trials. So, at the urging of ASOCF, the Treasury Department wants you to flip a Coin 20 times and print the number of heads and tails there were.
Implement the extraction and insertion (<< and >>) operators using friend functions.
Part I is worth 8 points. Part II is worth 10 points (Part I + 2 more points). Part III is worth 12 points (Part II + 2 points extra credit). The lab is out of 10 points. When you're done, submit your lab11.tar.gz file on Blackboard. I will be grading your program on the following criteria:
![[Dilbert]](dilbert.gif)