Helpful Ideas to get started

This is a discussion on Helpful Ideas to get started within the C++ Programming forums, part of the General Programming Boards category; This game should create a series of hidden symbols which the player needs to guess which symbols and the order. ...

Helpful Ideas to get started

This game should create a series of hidden symbols which the player needs to guess which symbols and the order. The symbols are !, @, &, and %. The string created using these symbols should have them in any order. The user gets to say how many symbols are in the string. Once the user selects the number, then the string is created randomly, and the user can then guess. There should be functions for creating the string and for comparing it to the player's choice. The string needs to be passed as a pointer to each of these functions

Hello I do not need you to do this for me just wanting ideas on how to go about getting the symbols to randomly mix up.

I know i need to set each of them = to a number so would

Code:

int Symbol()
{
! = 0
& = 1
% = 2
@ = 3
}

would this work or is there another way to do it?

Code:

int GetRandNum(int Max)
{
return rand() % max;
}

Max would be the number of symbols the user has selected to be in the puzzle.
I guess i dont understand how i get the symbols to jumble. I am a huge novice when it comes to C++ any ideas or help would be appreciated thanks

Your basically creating a string copy of the char array SYMBOLS and storing it into sequence. So their contents (and therefore size) will always be the exact same. You should just do something like

Code:

string sequence = "";

to create an empty string. You then later append to it, like

Code:

sequence += SYMBOLS[your_number]'

Also, instead of this

Code:

int index1 = (rand() % length);
int index2 = (rand() % length)

You want to "% 4".

If any of this is unclear why you should do it this way, then say so and I can explain. Its of no use to you if you just type things you are told without understanding why (especially during a test when you cant ask someone!)

Remove all of the lines in red, as I dont know what its doing, but if you just need to append to sequence, then you dont need the red lines. Also, change the "4" to "3" in the GetRandNum call, if you have verified that 3 is correct (to generate from 0 to 3).