setter - C++ NIM game logical error -
** The display is not working properly, the board will not show properly if applied within the main.
The code for this NIM game has been updated & lt; & Lt; Winner function and display function is not working properly ** I need help finding out how to get a display function to work properly.
class cboard {private: int sticks; Bull player; Public: // Default Constructor Cyboard () {sticks = 10;} // cursor with the given parameter (int x) {sticks = x;} // stick set zero setstick (int m) {sticks-= m;} / / Display stick carrier int_ get_sticks () {return sticks;} // display function, aka bard gesture blank display board (for (int i = blackjack; i>, i--) {cout
Your problem is in
displaycboard () . To read
loop
Change your code is not a loop that requires a variable to be changed. (int i = bars; i> i;) i ...) }
And it works fine due to repeated calls in the loop, it still outputs two lines (since the loop is iterative, and the beginning of the second loop First, the number of times at the same time calls with the sticks).
EDIT: A comment about your
goto BAD In context, you can change it with that thing
int s = 0; While (s & lt; = 2) {cout & lt; & Lt; "How many ... more than 2" & lt; & Lt; Endl; Cin & gt; & Gt; S; Second Editing: Your comment shows that you know that this is not secure, but you can enter a stringstream (
#include & lt; sstream & gt; ), And
std :: string instring; While (s & lt; = 2) {cout & lt; & Lt; "How many sticks you want to play with this game (greater than 2):"; Gateline (pin, insting); Stringstream (Insting) & gt; & Gt; S; }
This will allow you to enter something like
1.25 and the program will have to ask for a new value, or
5.25 and It will receive 5 play with a stick, note that <5> 5.99 still gives the sticks ...
Comments
Post a Comment