C++ removing cout ??
Hey im just making a game called yahtzee if anyone knows it for school and im having trouble with one part.
Let me explain the way the teacher wants the game to work. The are thirteen possible scores that the user can choose from after the dice roll randomly, then then next time the user can choose from the list of possible scoring systems again minus the one they already chose, all the way untill all thirteen scores are gone then the game prints the final score.
I was thinking of initalising the thirteen scoring outputs or something so anyway talked to much here is a segment of my code:
cout<<"\nPlease chose your scoreing system - remember you may only choose each one once: "<<endl;
cout<<"\n1. Ones - Adds all the ones to your score"<<endl;
cout<<"2. Twos - Adds all the twos to your score"<<endl;
cout<<"3. Threes - Adds all the threes to your score"<<endl;
cout<<"4. Fours - Adds all the fours to your score"<<endl;
cout<<"5. Fives - Adds all the fives to your score"<<endl;
cout<<"6. Sixs - Adds all the sixs to your score"<<endl;
so after user inputs i can compare and all just need to remove output from appearing next loop.
any help will be appreciated :)
So, build a table (of struct or class entries) that contains the text, which choice to select to use it ("1", "2" etc), and the result and a bool to indicate that the selection is available or not. Print only available entries for the user to choose from. Once it's "been used" set available to false.
When checking which choice was entered, run through the table and compare the choices with the choice the user used, and check that it's available (users are stupid, so they will press "2" even after choice 2 has been taken, so you need to make sure this "does the right thing", such as say "That choice isn't available").
so just as an example how would i create (well ive never used it so ill refer to int) liek the int value of that
char 1 = "ones ........ etc"
then remove from there, caus ethat what i was thinken of doing but dont know the right initalising name
sorry for stupid question new to this and all
thnx again :)
Ok, so you probably need to learn a little bit more C/C++ programming before what I said makes any sense. Try looking at tutorials for "struct".
haha i know this is getting annoying but we are only allowd to use upto what weve lernt, im in week 7 of school now, we just lernt arrays. alot of students get marked down for useing more advanced stuff than what weve lernt.
so i kinda have to make the program well stupid but functional.
Ok, so you use multiple arrays (one for string description ("ones", "twos", "full house", etc), one for which alternatives are available and not, and one for the resuling score for each entry) - it may be a good idea to discuss in some way with your teacher if that approach is OK - I'm sure that if you DISCUSS the idea, your teacher (or whoever is at hand to help you) will be able to help you with understanding the if your approach is OK or not.
thnx, ill look into what you said, ive been looking round for hours now, its just that most teachers - especially in programming are very unaproachable, kinda upthemselfs, like you should know everything they know or your just an annoyance, hate doing that so i just come here
If you're paying for the course, then you should be learning from them. You should ask them for help. ;)
I hate when teachers punish students for being advanced. If you already know the language, I think the last thing on your mind when you're about to do your assignment is, "What did we just cover up to now since that's all I can use?"
If you covered functions, you could make a new function to return the string version of your int. Corresponding arrays are probably better as matsp suggested, but there's more than one way to go about it.
Yes, being punished for using things you shouldn't is plain wrong, _UNLESS_ you are avoiding doing the task - e.g. calling strtol() isn't exactly writing some code to convert a string to integer.
Also, using an advanced method to solve a problem should be UNDERSTOOD by the student, not just "I've done this and it works, but I don't know why".
If an assignment states, "Compute xyz using recursion." then obviously recursion should be used, and the test there is probably to see if the student understands and can utilize recursion to solve a simple task. If the assignment just says, "Compute xyz." and recursive solutions are docked because it hasn't been covered in class yet, that's on the stupid side.
You'd still need some sort of array to know which entries the user has "used up" and which hasn't been taken yet - that's the key question in the original post, he poster wants to "remove" things that have been used. We obviously can't remove the "cout" itself, so we have to have a list of which ones can be used or not.
Originally Posted by MacGyver
[Edit: of course, it's technically possible to write self-modifying code to remove parts of the code, but that isn't within the scope of the original posters class, I would expect - nor would I recommend it for ANY other purpose either, except tiny embedded systems perhaps]