Archived

This topic is now archived and is closed to further replies.

SSJGaz

Loop Help

Recommended Posts

	switch(mainselection)						
	{
   
		case 1: 
			cout <<"\nYou Selected Full Systems. Please Wait...." << endl ;
			Sleep(2000);
			cout <<"\n1)Basic System\a"     << endl;
			Sleep(200); 
		    cout <<"2)Budget System\a"    << endl;
			Sleep(200);
			cout <<"3)Web System\a"       << endl;
			Sleep(200);
			cout <<"4)Avarage System\a"   << endl;
			Sleep(200);
			cout <<"5)Server System\a"    << endl;
			Sleep(200);
			cout <<"6)Storage System\a"   << endl;
			Sleep(200);
			cout <<"7)Power System\a"     << endl;
			Sleep(200);
			cout <<"8)All-Roind System\a" << endl;
			Sleep(200);
			cout <<"9)Uber System\a"    << endl;
			Sleep(200);
            cout <<"Please Choose An Option.\n" << endl;
			cin >> fullselection;
			cout <<"\nPlease Wait....\n" << endl;

 if( fullselection == 1)
{
cout <<"You Have Chosen To View Basic System Specs.\n" << endl ;
Sleep(1000);
cout <<"*Lynx K7SOM Mainboard" << endl;
Sleep(400);
cout <<"*Max CPU's - One. One 500Mhz Manufactured By DMA Supplied." << endl;
Sleep(400);
cout <<"*Hard Disk Slots - Two. 24GB Supplied." << endl;
Sleep(400);
cout <<"*Modem - 1Mb DSL Supplied." << endl;
Sleep(400);
cout <<"*Cost - 16500 CR\n" << endl;
cout <<"Would You Like To Purchase This System? (Y or N)" << endl;
cin >> &buybasicsystem[0];  
if( buybasicsystem[0] == 'y')	
{
cout <<"Checking Credit Funds.\n" << endl;
Sleep(2000)
;if(money < 16500)
Sleep(1000)
;cout << "Error Insufficient Funds." << endl;
}
how do i get the source in box 1, to loop at the end of the source in box 2? [edited by - SSJGaz on July 27, 2003 7:23:58 PM] [edited by - SSJGaz on July 27, 2003 7:24:40 PM]

Share this post


Link to post
Share on other sites
I do not understand your questions, but if you wonder how to make loop of the menu system, this is what you need:


bool bExit = false;
int iSelection = -1;
while (bExit != true) // This is the same as: while (!bExit)

{
DisplayMenu();
cin >> Selection;
switch (iSelection)
{
case 1: DoSomething(); break;
case 2: DoSomeMore(); break;
case 0: bExit = true; break; // We end the loop in here

default: cout << "Invalid selection"; break;
}
}


And please, lose the calls to Sleep(). It''s annoying for your teacher to test a program that is that slow(It looks like a C++ class assignment).

Toolmaker



-Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites
quote:
Original post by Toolmaker
I do not understand your questions, but if you wonder how to make loop of the menu system, this is what you need:


bool bExit = false;
int iSelection = -1;
while (bExit != true) // This is the same as: while (!bExit)

{
DisplayMenu();
cin >> Selection;
switch (iSelection)
{
case 1: DoSomething(); break;
case 2: DoSomeMore(); break;
case 0: bExit = true; break; // We end the loop in here

default: cout << "Invalid selection"; break;
}
}


And please, lose the calls to Sleep(). It''s annoying for your teacher to test a program that is that slow(It looks like a C++ class assignment).

Toolmaker



-Earth is 98% full. Please delete anybody you can.


my teacher? o0 Its not slow, it adds to the effect of the game. since its a console game i dont want the whole text to show up on the screen at once i would rather have it show up line by line.

--

as 4 my question. I want my program to go back to that menu AFTER the user finds out that he/she hasnt got enuff money.

Share this post


Link to post
Share on other sites
ok lets do it this way

ill call the source in box 1 A
ill call the source in box 2 B

now i want

A > B > A

so thats

From the menu, to the money checking thing then back to the menu if the user does not have enuff money.

(Note - look at the source in box 2 again, i added more)

[edited by - SSJGaz on July 27, 2003 7:25:23 PM]

Share this post


Link to post
Share on other sites
Ohh, ok, then you could just make that if loop into a while loop, use it before the switch and say something like this ....


while( buybasicsystem[0] != ''y'')
{
// do my funky stuff
}


quote:
Original post by Anonymous Poster
hi tiffany!



hi

Share this post


Link to post
Share on other sites
quote:
Original post by SSJGaz
this is all very complicated :'(

i dont want to change the possition of any of my code. i just want to add some SMALL THINGS or else ill break it :'(


This is the only way youre gonna get it to work, you just changed the example you originally posted but if you post all the code, myself or someone else, can fix it for you and point you in the right direction, try not to be afraid of it, otherwise you wont get anywhere ... always save when you make a change and if all else fails you can go back to your previous bulid.


[edited by - Tiffany_Smith on July 27, 2003 8:54:35 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Tiffany_Smith
quote:
Original post by SSJGaz
this is all very complicated :''(

i dont want to change the possition of any of my code. i just want to add some SMALL THINGS or else ill break it :''(


This is the only way youre gonna get it to work, you just changed the example you originally posted but if you post all the code, myself or someone else, can fix it for you and point you in the right direction, try not to be afraid of it, otherwise you wont get anywhere ... always save when you make a change and if all else fails you can go back to your previous bulid.


[edited by - Tiffany_Smith on July 27, 2003 8:54:35 PM]


thx for the offer. if i cant manage to do it myself, ill contact you

Share this post


Link to post
Share on other sites
quote:
Original post by SSJGaz
quote:
Original post by Tiffany_Smith
quote:
Original post by SSJGaz
this is all very complicated :''(

i dont want to change the possition of any of my code. i just want to add some SMALL THINGS or else ill break it :''(


This is the only way youre gonna get it to work, you just changed the example you originally posted but if you post all the code, myself or someone else, can fix it for you and point you in the right direction, try not to be afraid of it, otherwise you wont get anywhere ... always save when you make a change and if all else fails you can go back to your previous bulid.


[edited by - Tiffany_Smith on July 27, 2003 8:54:35 PM]


thx for the offer. if i cant manage to do it myself, ill contact you



Ok, good luck

btw: that''s a much better attitude .

Share this post


Link to post
Share on other sites