simple game menu

im a beginner at this still getting comfortable in programming c++. there are things i still can't wrap my mind in some of the subject. please help on this menu program , i have look through my other program that is working and kinda compare to it. like some of blank constructor idk how to rackle that, i have to write a program that simulates a handheld gaming system. a system can have power toggled so its either on or off. when the system is on, its volume level can be raised or lowerd. a system has minimum volume level of zero and a maximum volume level of 10. a system stores games.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// simple game menu
//simulates a handheld gaming system

using namespace std;

class Game

{
      
       
public:
      Game(int GameNumber = 3, int volume = 10);
       static const int NUM_GAMES = 3;
       static const string GAMES[NUM_GAMES];
       static const int MIN_VOLUME=0;
       static const int MAX_VOLUME = 10;
       void TogglePower();
       void DisplayGames()const;
       void Play()const;
       void SetGameNumer(int newGameNumber);
       void RaiseVolume();
       Void LowerVolume();
       bool m_Ison;
private:
       int m_GameNumber;
       int m_Volume;
};

Game::Game(int GameNumber = 3, int volume = 10);
      m_GameNumber(GameNumber)
      m_Volume(volume)
      
{}
void Game::TogglePower();
{ 
}
  bool m_Ison()
  {
       
}

void Game::DisplayGames()const;
{ 
   Game games;
   int i;
   do
   { 
     cout << "The system comes with the following built-in games:\n";
     cout << "0 - Generic Mascot Platformer\n";
     cout << "1 - Overly Cute Kart Racer\n";
     cout << "2 - Derivative Block puzzler\n";
     cout << "\n\n Enter a game number: " << i << endl;
     switch(games)
     {
                 case 0:
                      cout << "Games set\n";
                      break;
                 case 1:
                      cout<< "Games set\n";
                      break;
                 case 2:
                      cout<< "Games set\n";
                      break;
                 default:
                         cout <<"\n Sorry, there is no game number"<< i<< "."<<endl;
                         cout << "try a game number between 0 and 2.";
     }
     
     
}

void Game::Play()const;
{

}

void Game::SetGameNumber(int newGameNumber)
{
}

void Game::RaiseVolume()
{
     cout << "Volume Raised.\n";
     if (m_Volume > 10)
          m_Volume = 10;

 }
 
 void Game::LowerVolume()
{
      cout << "Volume Lowered.\n";
      if (m_Volume < 10)
          m_Volume = 10; 
}

int main()
{ 
    Game menu;
    int choice ;
    do
    {     
          cout << "\n\n Welcome to the Handheld Game System Simulator!\n\n";
          cout<<"\n\n Handheld Game System\n\n";
          cout << " 0  - Quit \n";
          cout << " 1 - Toggle the system power\n";
          cout << " 2 - Select a game for the system\n";
          cout << " 3 - Raise the system volume\n";
          cout << " 4 - Lower the system volume \ n";
          cout << " 5 - Play the system\n";
          cout << "Choice\n\n";
          cin >> choice;
          switch(choice)
          {
                        case 0: Quit;
                        break;
                        case 1: menu.TogglePower();
                        break;
                        case 2: menu.DisplayGames();
                        break;
                        case 3: menu.RaiseVolume();
                        break;
                        case 4: menu.LowerVolume();
                        break;
                        case 5: menu.Play();
                        break;
                        default:
                                cout<< "\nSorry, but " << choice << " isn't a valid choice.\n";
        }while( choice != 1);
        }
        return 0;            
}

     
Last edited on
closed account (o3hC5Di1)
Hi there,

I'm not entirely sure what the problem is, but I assume it's with the DisplayGames() member function:

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
void Game::DisplayGames()const;
{ 
   Game games;
   int i;
   do //You start a do/while loop here, bu you have no "while" clause in your code.
   { 
     cout << "The system comes with the following built-in games:\n";
     cout << "0 - Generic Mascot Platformer\n";
     cout << "1 - Overly Cute Kart Racer\n";
     cout << "2 - Derivative Block puzzler\n";
     cout << "\n\n Enter a game number: " << i << endl;
     switch(games)
     {
                 case 0:
                      cout << "Games set\n";
                      break;
                 case 1:
                      cout<< "Games set\n";
                      break;
                 case 2:
                      cout<< "Games set\n";
                      break;
                 default:
                         cout <<"\n Sorry, there is no game number"<< i<< "."<<endl;
                         cout << "try a game number between 0 and 2.";
     } //There should be a while-clause like while(games > 2 && games <0)
     
     
}



Hope that helps. If you need any further help, please come back to us with a more detailed description of your problem

All the best,
NwN
Topic archived. No new replies allowed.