Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You operate several hot dog stands distributed throughout town. Define a class n

ID: 3683794 • Letter: Y

Question

You operate several hot dog stands distributed throughout town. Define a class named HotDogStand that has a member variable for the hot dog stand's ID number and a member variable for how many hot dogs the stand has sold that day. Create a constructor that allows a user of the class to initialize both values.

Also create a method named justSold() that increments the number of hot dogs the stand has sold by one. The idea is that this method will be invoked each time the stand sells a hot dog so that we can track the total number of hot dogs sold by the stand. Add another method that returns the number of hot dogs sold.

Finally, add a static variable that tracks the total number of hotdogs sold by all hot dog stands and a static method that returns the value in this variable.

Write a main method to test your class with at least three hot dog stands that each sells a variety of hot dogs. In C++ please.

Sample output (bolded text denote input from user)

Stand 1 sold 2

Stand 2 sold 1

Stand 3 sold 0

Total sold = 3

Stand 1 sold 3

Stand 2 sold 1

Stand 3 sold 1

Total sold = 5

Explanation / Answer

#include <iostream>

using namespace std;

class HotDogStand
{
public:
  
static int total;
// Constructor definition
HotDogStand(int para_ID)
{
ID = para_ID;
sold = 0;
}

void justSold()
{
sold++;
total++;
}
int returnSold()
{
return sold;
}


private:
int ID;
int sold;
};

// Initialize static member of class Box
int HotDogStand::total = 0;

int main()
{
HotDogStand stand1(1);
HotDogStand stand2(2);
HotDogStand stand3(3);

stand1.justSold();
stand1.justSold();
stand2.justSold();

cout<<"stand1 sold "<<stand1.returnSold()<<" hot dogs ";
cout<<"stand2 sold "<<stand2.returnSold()<<" hot dogs ";
cout<<"stand3 sold "<<stand3.returnSold()<<" hot dogs ";
cout<<"total "<<stand1.total<<" hot dogs sold ";

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote