Question
C++ MUG.CPP BELOW #include Mug.h #include //we are adding ostream and istream #include using namespace std; //these comments should help you, as the programmer of
C++
MUG.CPP BELOW
#include "Mug.h"
#include
#include
using namespace std;
//these comments should help you, as the programmer of this out
//i.e. everyone else who gets handed this code
//should rely on the comments in the .h file
//Member Constants
int Mug::howManyMugs = 0; //keeps track of how many mug instances have been created.
/**IMPLEMENT Constructor with an initial fill passed in
make sure initial fill is greater than 0 or less than CAPACITY
Add one to how many mugs static variable*/
Mug::Mug(double initialFill)
{
}
/**IMPLEMENT** adds the fill amount to the mug (positive or negative)
make sure it's not filling THE MUG to an amount greater
than CAPACITY or less than 0, if it does set it to capacity or 0*/
void Mug::fillMug(double fillAmount) //**IMPLEMENT** adds the fill amount to the mug (positive or negative)
//make sure it's not filling it to an amount greater
{ //than CAPACITY or less than 0, if so set it to capacity or 0 respectively
}
/*EMPTY IS IMPLEMENTED FOR YOU */
void Mug::empty()
{
amountFilled = 0;
}
/*NOTE GET FILL AMOUNT IS NOW INLINED in the .h! Also you don't have implement it
BUT CHECK OUT THE INLINING SYNTAX*/
/*IS EMPTY IS IMPLEMENTED FOR YOU */
bool Mug::isEmpty() const //checks if the mug is empty and return
{
return (amountFilled == 0.0);
}
/**IMPLEMENT** assigns the amount in the calling mug object to the same amount
as the mugToCopy object. Note that this is a member denoted by mug::*/
void Mug::operator = (const Mug& mugToCopy) //IMPLEMENT THIS!
{
}
/**IMPLEMENT** checks if the amount in the calling mug object is greater than
the mugToCopy object. Note that this is a member denoted by mug::*/
bool Mug::operator > (const Mug& mugToCompare) const //IMPLEMENT THIS
{
return false;
}
/**IMPLEMENT** checks if the amounts in two mugs are equal. NOTE THIS IS NOT A
MEMBER and thus both mugs are passed in (there is no calling object)*/
bool operator ==(const Mug &firstMug, const Mug &secondMug) //IMPLEMENT THIS
{
return false;
}
/*IMPLEMENT THIS: CIN (i.e. Operator >> is ALMOST implemented for you
BUT it doesn't quite work...think about what values amount filled can be set to*/
/*Google overloading cin and cout in c++ if you are having trouble*/
istream& operator >>(istream& ins, Mug& target)
{
ins >> target.amountFilled;
return ins;
}
/*IMPEMENT THIS--outputs the amount filled-- you can use operator >> as a guide
Remember outs is like cout so you can do the same things with it
and then return it. Note this is a non-member so the mug that needs
to be couted is explicitly passed in*/
ostream& operator
{
return outs;
}
A Mug is represented by an amount filled. Go through the mug class and implement everything where it says /**Implement in mug.cpp Implement all the necessary functions in mug.cpp! You shouldn't need to touch main or mug.h Fill mug and the constructor should use the following couts if someone tries to fill a mug more than the capacity or less than 0 cout
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started