Loop Help

Started by
18 comments, last by SSJGaz 20 years, 8 months ago

	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]
[SSJGaz][Newbie C++ Programmer]
Advertisement
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.

Either put the code in the first example at the end of the code in the second example or put both into functions and call one from the other?

Or did i misunderstand your question?

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.
[SSJGaz][Newbie C++ Programmer]
hi tiffany!
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]
[SSJGaz][Newbie C++ Programmer]
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

quote:
hi


*gives a rose to Tiffany*
quote:Original post by Anonymous Poster
*gives a rose to Tiffany*



Thank you, how nice

quote:
Thank you, how nice

whoohooo!!!

This topic is closed to new replies.

Advertisement