Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Object-Oriented Programming C++ - Make a class called HotdogStand with these requirements met. The Money class definition is included in the question. I've done the

Object-Oriented Programming C++ - Make a class called HotdogStand with these requirements met. The Money class definition is included in the question. I've done the declarations for the HotdogStand class so I need the definition of the class done according to the requirements below. Thanks and I'll be sure to give an upvoteimage text in transcribedimage text in transcribed

#include

#include

Money::Money() : dollars(0), cents(0)

{

}

Money::Money(int dol, int cen)

{

dollars = dol;

cents = cen;

if(dollars 0){

cents = -cents;

}

if(cents 0){

dollars = -dollars;

}

if(cents > 100){

dollars += cents / 100;

cents %= 100;

}

}

Money::Money(int dol)

{

dollars = dol;

cents = 0;

}

Money::Money(double amt)

{

dollars = amt;

cents = (amt * 100 - dollars * 100);

}

int Money::getPennies() const

{

return dollars * 100 + cents;

}

void Money::setMoney(int d, int c)

{

dollars = d;

cents = c;

}

bool Money::isNegative() const

{

if(dollars

return true;

}

else {

return false;

}

}

void Money::add(const Money &m)

{

int pennies = getPennies() + m.getPennies();

dollars = pennies / 100;

cents = pennies % 100;

}

void Money::subtract(const Money &m)

{

int pennies = getPennies() - m.getPennies();

dollars = pennies / 100;

cents = pennies % 100;

}

bool Money::isEqual(const Money &m) const

{

if(getPennies() == m.getPennies()){

return true;

}

else {

return false;

}

}

void Money::print() const

{

if(isNegative()) {

double x = (-(((double)dollars))) + (-(((double)cents)/100));

std::cout

}

else {

double x = ((double)dollars) + (((double)cents)/100) ;

std::cout

}

}

The HotdogStand class shall have two (2) constructors - A default constructor that initializes your HotdogStand object with no cash, a price of $3.50, and no hotdogs sold - A constructor that takes a double, and initializes your HotdogStand object with no cash, the provided hotdog price, and not hotdogs sold const Money getCash) const - This returns the total cash the HotdogStand has const Money getPrice ) const int getDogs Sold) const - This returns the number of hotdogs sold by the stand const Money getStandRevenue ) const This calculates the total money made by selling hotdogs void setPrice (double price) void sellHotdog) - Increments all appropriate data members accordingly static int getNumStands ) static int getTotalHotdogsSold static const Money get TotalRevenue) The Hot dogStand class shall have six (6) private data members - A Money object that will represent how much money the stand has made - A Money object that will represent the price of a hotdog - An integer that will describe how many hotdogs a stand has sold - A static integer that represents the total number of HotdogStand objects - A static integer that represents the total number of hotdogs sold

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions