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 sell a variety of hot dogs.
so for I had this
class HotDogStand
{
public:
HotDogStand();
HotDogStand(int newID, int newNnumSold);
int GetID();
void SetID(int);
void JustSold();
void JustSold(int count){NSold += count;};
int GetNumSold(){return NSold;};
int GetTotalSold(){return TotalSold += NSold;};
private:
int NID,NSold, TotalSold, count;
};
int main()
{
HotDogStand s1(1,0);
HotDogStand s2(2,0);
HotDogStand s3(3,0);
HotDogStand s4;
s1.JustSold();
s2.JustSold();
s1.JustSold();
s4.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 << "Stand " << s4.GetID() << " sold " << s4.GetNumSold() << endl;
cout << "Total sold = " << s1.GetTotalSold() << endl;
cout << endl;
s3.JustSold();
s1.JustSold();
s2.JustSold(5);
s1.SetID (99);
s4.SetID(4);
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 << "Stand " << s4.GetID() << " sold " << s4.GetNumSold() << endl;
cout << "Total sold = " << s1.GetTotalSold() << endl;
cout << endl;
system("pause");
return 0;
}
int HotDogStand::GetID() {
return NID;
}
void HotDogStand::SetID(int newID){
NID= newID;
}
HotDogStand::HotDogStand()
{
NID = 0;
NSold = 0;
}
HotDogStand::HotDogStand(int newID, int newNnumSold)
{
NID = newID;
NSold = newNnumSold;
}
void HotDogStand::JustSold()
{
NSold++;
}
output:
Stand 1 sold 2
Stand 2 sold 1
Stand 3 sold 0
Stand 0 sold 1
Total sold = -858993458
Stand 99 sold 3
Stand 2 sold 6
Stand 3 sold 1
Stand 4 sold 1
Total sold = -858993455
Press any key to continue . .
how can I fix the total stand