Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You operate several hot dog stands distributed throughout town. Define a class named HotDogStand that has a member variable for the hot dog stands ID

You operate several hot dog stands distributed throughout town. Define a class named HotDogStand that has a member variable for the hot dog stands ID number and a member variable for how many hot dogs the stand sold that day. Create a constructor that allows a user of the class to initialize both values. Also create a function named JustSold that increments the number of hot dogs the stand has sold by one. This function will be invoked each time the stand sells a hot dog so that you can track the total number of hot dogs sold by the stand. Add another function that returns the number of hot dogs sold. Finally, add a static variable that tracks the total number of hot dogs sold by all hot dog stands and a static function that returns the value in this variable. Write a main function to test your class with at least three hot dog stands that each sell a variety of hot dogs.

Here is your main funciton:

int main() { // Test our code with three hot dog stands 
 HotDogStand s1(1,0); 
 HotDogStand s2(2,0);
 HotDogStand s3(3,0); // Sold at stand 1, 2 s1.JustSold(); s2.JustSold(); s1.JustSold(); cout << "Stand " << s1.GetID() << " sold " << s1.GetNumSold() << endl; cout << "Stand " << s2.GetID() << " sold " << s2.GetNumSold() << endl; cout << "Stand " << s3.GetID() << " sold " << s3.GetNumSold() << endl; cout << "Total sold = " << s1.GetTotalSold() << endl; cout << endl; // Sold some more s3.JustSold(); s1.JustSold(); cout << "Stand " << s1.GetID() << " sold " << s1.GetNumSold() << endl; cout << "Stand " << s2.GetID() << " sold " << s2.GetNumSold() << endl; cout << "Stand " << s3.GetID() << " sold " << s3.GetNumSold() << endl; cout << "Total sold = " << s1.GetTotalSold() << endl; cout << endl; return 0; }

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 3 Lnai 9853

Authors: Bettina Berendt ,Bjorn Bringmann ,Elisa Fromont ,Gemma Garriga ,Pauli Miettinen ,Nikolaj Tatti ,Volker Tresp

1st Edition

3319461303, 978-3319461304

More Books

Students also viewed these Databases questions

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago

Question

d. Who are important leaders and heroes of the group?

Answered: 1 week ago