I am having a lot of trouble writing this program. It is basically keeping track of sales. But I am not getting any values passed from the main function to the class functions. ex Id is not passing to the func JustSold. I am also having trouble with my static variable TotalSales. Can anyone help?....
Thanks
Thanks
Code:
#include <iostream>
#include <iomanip>
using namespace std;
#define W setw
class HotDogStand{
private:
static double TotalSales;
public:
int StandID;
int StandSales[];
void Setup ();
void CreateStand ();
void JustSold (int);
void ShowSales (int);
int Menu ();
static void ShowTotalSales ();
};
void HotDogStand::Setup (){
StandID = 0;
return;
}
void HotDogStand::CreateStand (){
char answer[1];
cout << "Do you want to create a new stand (y/n) ";
cin >> answer;
if (answer[0] == 'n' || answer[0] == 'N'){
return;
}
++StandID;
StandSales[StandID] = 0;
cout << "Stand #" << StandID << " created!" << endl << endl;
return;
}
void HotDogStand::JustSold (int StandD){
++StandSales[StandID];
++TotalSales;
return;
}
void HotDogStand::ShowSales (int StandID){
cout << "Stand #" << StandID << " has sold " << StandSales[StandID] << " hotdog(s)! " << endl << endl;
return;
}
void HotDogStand::ShowTotalSales (){
cout << TotalSales << " hotdog(s) have been sold!" << endl;
return;
}
int HotDogStand::Menu (){
int option;
cout << "Welcome, what would you like to do: " << endl;
cout << W(7) << "1." << W(4) << "Create New Stand" << endl;
cout << W(7) << "2." << W(4) << "Report New Sale" << endl;
cout << W(7) << "3." << W(4) << "Show Sales of Specific Stand" << endl;
cout << W(7) << "4." << W(4) << "Show Total Sales" << endl;
cout << W(7) << "5." << W(4) << "Quit" << endl;
cin >> option;
return option;
}
int main(void){
int option, ID;
HotDogStand A;
A.Setup();
while (true){
option = A.Menu();
if (option == 1){
A.CreateStand();
}
else if (option == 2){
cout << "Please Enter Stand ID#: ";
cin >> ID;
A.JustSold (ID);
}
else if (option == 3){
cout << "Please Enter Stand ID#: ";
cin >> ID;
A.ShowSales (ID);
}
else if (option == 4){
A.ShowTotalSales();
}
else if (option == 5){
return 0;
}
}
return 0;
}
Comment