Need to set a max value on an integer

So right now at the moment im working on a project for class, we are assigned to make a game of our choice and i took this as an opportunity to really get creative and im having trouble finding out how to set a max value for one of my integers.

Heres what i've done so far ( About 2 days)

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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#include <iostream>
#include <stdlib.h>
#include <string>
#include <limits>
using namespace std;
string name;
string friend1;
int choice;
float money = 100;
int energy = 20;
int workexp = 0;
float wage = 8.25; 
int expreq = 50;
int health = 100;
int day = 1;

// Everything is somewhat out of order, move everything around later...

int main ()
{   
	

cout <<" Before we begin Life please start by filling out your Character's qualities"<<endl<<endl;
  cout<< " Press Enter to continue...";
  cin.ignore();
  
	cout <<" What is your name going to be?"<<endl;
	cout << "       Name:";
	cin >> name;
	cin.ignore();
	cout <<"\n This is Alpha version 0.0.1 \n\n\n";

	cout <<"      From here on out you decide "<<name<<"'s life, good luck...\n\n\n\n\n";

	cout<<" Press Any key to Start \n\n\n";

   cin.ignore();
      cout <<" You wake up in your bedroom, its morning. \n\n";
homeloop:
	  cout<<"Day "
		  
		  <<day<<endl<<endl;
	  cout <<"1) Take a shower \n";

	  cout <<"2) Sleep \n";
	  cout <<"3) Map \n";
	  cout <<"4) Eat \n";
	  cout <<"5) Leave \n";  
	     cin >>choice;

		 if (choice == 1)
		 {
			 cout <<"You take a shower and recover 10 hp \n\n";
			 cin.ignore();
			 health = health + 10;
			 cout <<" What now? \n";
			 goto homeloop;
		 }
		 else if (choice == 2)
		 {
			 cout <<" You sleep and regain your energy \n\n";
				energy = energy + 20;
				day = day + 1;
			 goto homeloop;
		 }
		 else if (choice == 3)
		 {
		 cout <<" 1) Job \n";
			      cout <<" 2) Mall \n";
				  cout <<" 3) School \n";
				  cout <<" 4) Food District \n";
				  cout <<" 5) Store \n";
				  cout <<" 6) Apartments \n\n";


		cout <<" Where would you like to go? \n";
          cin >> choice;
                 if (choice == 1)
				 {
workloop:
	cout<< " What would you like to do? \n";	cout<< "1) Work (-2 Energy)\n";
	cout<< "2) Ask for promotion \n";
	cout<< "3) Leave \n";

	   cin>> choice;

	   if (choice == 1)
	   {
		   if (energy >= 2)
		   
		   { cout<<" You Stock shelves \n";
		   cout<<"+ $"<< wage<<endl;
	      money = money + wage;
		  energy = energy - 2;
	     workexp = workexp + 5;
		  cout<<money<<endl;
	   cout<<energy;
	   goto workloop;}
		   else
			   cout<<" You dont have enough enrgy to work";
		   goto workloop;
	   }
	      if (choice == 2)

		  {
			  cout << " You ask your boss for a promotion...\n";
			  cin.ignore();  
			  if (workexp >= expreq)
				{
					cout<< " You are successful! \n\n";
                  expreq = expreq + 75;
					cout<< "    Pay + $2 \n";
					wage = wage + 2;
					cout<<"     New salary = "<<wage;
					}
			  else
				  cout << " You dont have enough Work experience";
			  goto workloop;
		  }

		  if (choice == 3)

		  {
			  cout <<" Where would you like to go? \n\n";

				  cout <<" 1) Home \n";
			      cout <<" 2) Mall \n";
				  cout <<" 3) School \n";
				  cout <<" 4) Food District \n";
				  cout <<" 5) Store \n";
				  cout <<" 6) Apartments \n\n";    
                 
				  cin>>choice;
				  if (choice ==1)
				 {
					 goto homeloop;
				 }
		  
		  }



				 }
		         
		 }

		 if (choice == 4)
		 { 
             cout <<"You put together a simple breakfast \n";
				 cout <<" + 1 hunger"<<endl; 
               cin.ignore();
			   goto homeloop;
		 }

		 if (choice == 5)
		 {
			 cout <<" Outside of your house you run into one of your childhood friends \n ";
			 cout <<"Name of friend:";
			 cin>>friend1;
			 cout << "You greet "<<friend1<<endl<<endl;
			 cout << "1) Hey, whats up? \n";
			 cout << "2) I hate your face! \n\n";
			 cin>>choice;
			       if (choice == 1)
				   {
					   cout<<"You: Hey, whats up?\n";
						   cout <<friend1<<": Nothing at the moment, im heading to the mall you should stop by later\n\n";

						   cout<<"1) Yeah, i'll make sure to do that\n";
						   cout<<"2) Make excuse* \n";
						   cout<<"3) Turn down* \n";

							   cin>>choice;
							   {
                                   if (choice == 1)
								   {
									   cout<<"You: Yeah, I'll make sure to do that \n";
									   cout<<friend1<<": Great! I'll be at Vivid, i've got to go now \n\n";
										   cout <<"Relationship +20";
								   
								   
								   }
                           //Bug around here, fix whenever you get the chance
								   if (choice == 2)
								   {
									   cout <<"You: Im sorry but im going to be busy \n";
									   cout <<friend1<<": Thats ok maybe another time";

								   }
							   }
				   // Fixed now i beleive 
				   
                   if (choice == 2)
				   {  cout <<"You: I hate your face! \n";
				   cout <<friend1<<": Whats your problem, Im leaving now \n\n";
					   cout <<friend1<<" left, insult was very effective -20 relationship points";


				   }

				     }

		 
		 
		 }





   



  cin.get();
return 0;
}


I want to set a max value of 20 for my energy int that way you cant just 'sleep' a couple times and have enough energy to go through the game without having to return home to sleep, I was also thinking of implementing a way of increasing your max energy that way you can start the day out with more energy, for example maybe you could work out for -5 energy and you max energy would go up 1.

*I know using if and else if statements gets really messy but im limited to only using them since thats what we've just gone over, i plan on possibly switching it to case statements after i've turned in the assignment, I will most likely continue on with this game just for fun.

Thanks in advance.
Topic archived. No new replies allowed.