Quote (thebigman1212 @ May 11 2014 04:16pm)
well basically it's a small card game
(the program is for a introduction to c++ online class)
it involves having 10 void statements with the design of the cards
The first card is picked for the computer out of the 10.
then the user gets to pick a card from the 10 choices.
so I have
if choice = 1
{
10 if statements
}
if choice = 2
{
10 if statements
}
etc...
If i could just call the void based on the user choice, then I would only need 1 if statement for each choice statement
My voids have no crucial info, just design
i'm still not clear on what you're doing. if i understand you correctly, there's a 52 card deck, and 10 cards are dealt on the table. then the computer chooses 1, then player chooses one, repeat? i don't see how that equates to 10 choices x 10 more if statements = 100 if statements. show some concrete code and we can prolly refactor it.
if those 10 inner if statements to determine which function to call are always the same, then just have one function with the 10 if statements, then in each block call that one function.
eg:
Code
void delegate(int choice){
if (choice == 1){
function1();
} else if (choice == 2){
function2();
}
.....
}
if choice = 1
{
delegate(1);
}
if choice = 2
{
delegate(2);
}
or just skip that altogether and call delegate(choice);
again, i have to see what your code is to give more input.
Quote
Your code is correct
sheer luck
This post was edited by carteblanche on May 11 2014 02:50pm