{ switch(card) {case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
count++;
break;
case 7:
break;
case 8:
break;
case 9:
card = '';
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
card = -1;
if (card > 0) {return "bet";}
else {return "hold";}
return card; }
I assume this is what is holding me back. Iām trying to avoid looking at the answer, but had to for the count partā¦ and now I want to understand the logic of this
By the way, this method of asking why has helped me with solving novel problems independently, so I greatly appreciate the help.
What is going on here? Why are you setting the argument (card) to an empty string? Similarly, are you sure that you are supposed to set card to negative one for J, Q, K, and A.
Every block where you have
case <something>:
break;
You are setting your case statement to do nothing for those values. break means to break out of the switch statement entirely. Your switch statement does not perform any operations for the values 2, 3, 4, 5, 7, and 8.
I also believe that you need to look more carefully at what you are supposed to return.
Having seen a few of your in-progress solutions, Iād like to offer some general advice when it comes to your approach:
Read the instructions very carefully. Read the instructions several times. Break them down and make sure you know exactly what the expected results should be.
Work on your solutions in small steps. Start with the most basic requirements or the simplest case from the instructions and focus on getting that right. Then build off of that.
I feel incredibly bad for asking when I do, but sometimes I donāt understand the questions. This has occured less over time, but especially when I was learning what a switch was (how I should think about it so that I respond to situations where a switch would be useful correctly, I mean), I had trouble making an action plan and responding to a novel situation. Would you suggest writing a āto doā list:
I have actually solved some of the questions while I was critically thinking about it before a moderator has given me advice about what to do. But I will keep your advice in mind.
Did you have a question? Was there something we could help you with? In general, when you have a question it is best to create your own forum topic, instead of adding your question to an older topic.