Hi all,
I'm new to programming and I am currently taking an intro class that is requiring me to create Wheel of Fortune in c ++.

I've made some decent head-way (I think), but I'm still far from getting this right.

Here's what I have so far:

*NOTE* The function prototypes are guideline that my professor has given us. As you can see, I haven't used all of them yet.. I'm still having trouble getting the program to execute with what I have.

//Wheel of Fortuane Program

#include<ctime>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;
//=============================================================================
//Function Prototypes
int spin_wheel();
char isvowel(char guess);
void print_puzzle (string puzzle);
void print_score (int players, int score[]);
void initialize_arrays (string& phrase, string& puzzle);
void printHeading();
bool buy_vowel (int player, int score, string phrase, string& puzzle, char guess);
bool spin (int player, int score[], string phrase, string& puzzle);
bool player_turn (int player, int score[], string phrase, string& puzzle);
bool solve (int player, int score[], string phrase, string& puzzle);
//=============================================================================
//Global Constants
const string STAR = "*";
const int MAX = 14;
const int PHRASE_SIZE = 81;
const int NUM_PLAYERS = 3;
const int VOWEL_COST = 250;
const int BANKRUPT = 0;
const int LOSE_TURN = -1;
const int WHEEL_SIZE = 15;
const int WHEEL[WHEEL_SIZE] = 
	{50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 1000, 1500, 2500,
	BANKRUPT, LOSE_TURN};
//=============================================================================


int main()
{
//Declaring variables
	string puzzle, phrase;
	int player, score[NUM_PLAYERS];
//Function call to open a data file that contains the phrase
	initialize_arrays(phrase, puzzle);
//Function call to initialize the player's turn
	player_turn(player, score, phrase, puzzle);
	return 0;
}

//=============================================================================
//Function call to open file and put it into an array
void initialize_arrays (string& phrase, string& puzzle)
{
	int count;
	ifstream inFile;
	string userInput;

//Error test loop
	cout << "Please enter a file name you wish to open ->";
	cin >> userInput;
	inFile.open(userInput.c_str());

	while(!inFile)
	{
		inFile.clear();
		cout << "Please enter a valid file name->";
		cin >> userInput;
		inFile.open(userInput.c_str());
	}
	
	cout << "Here is your phrase: " << endl;

//Loop to store phrase into array
	
	getline(inFile, phrase);


	for(count = 0; phrase.length() > count; count ++)
	{
		puzzle.insert (count, STAR);
	}	

	cout << puzzle;
	cout << endl << endl;

	inFile.clear();
	inFile.close();
}
//=============================================================================
//Function to print the file's heading
void printHeading()
{
	cout << "Welcome to Wheel of Fortune!" << endl;
}

//=============================================================================
//Function that generates what the wheel spin's value will be
int spin_wheel()
{	
	int spin;
	unsigned seed = time(0);
	srand(seed);
	spin = rand() % 14;
	cout << WHEEL[spin] << endl << endl;
	return(spin);
}

//=============================================================================
//Function that prints the phrase array after the puzzle has been solved
void print_puzzle(string phrase)
{
	cout << "CONGRATULATIONS! You've solved the puzzle:" << phrase << endl;
}

//=============================================================================
//Function that directs the players turn
bool player_turn (int player, int score[], string phrase, string& puzzle)
{
//Declaring local variables
	char choice, letter;
	bool validChoice = false;

	cout << "What would you like to do with your turn?" << endl;
	cout << "Here are your options:" << endl;
	cout << "(s)pin the wheel, s(o)lve he puzzle, or (b)uy a vowel" << endl;
	cout << "Type the corresponding lower case letter in () to move on ->";
	cin >> choice;

//Loop to make sure the player entered a valid character to execute
//a function
	while (!validChoice)
	{
		validChoice = false;
		switch (choice)
		{
			case 's': spin_wheel();
				cout << endl;
				cout << "Choose a letter ->";
				cin >> letter;
				cout << endl;
				validChoice = true;
				break;
			case 'o': bool solve (int player, int score[],string phrase,string& puzzle);
				cout << endl;
				validChoice = true;
				break;
			case 'b': bool buy_vowel(int player, int score[], string phrase, string& puzzle, char guess);
				cout << endl;
				validChoice = true;
				break;
			default : cout << "Please make sure you typed a lower case letter" << endl;
		}
	}
	return(player_turn);
}	

//=============================================================================
//Function to determine if the letter the user selects is a vowel
char isvowel (char guess)

{
//Declaring local variables
	char userGuess;
	bool notVowel = false;
	enum VOWELS {a, e, i, o, u};
//Getting the player's guess
	cout << "Please enter the vowel you wish to buy ";
	cout <<	"as a lowercase character ->";
	cin >> userGuess;
	
//Error checking loop to make sure player entered a recognized vowel
	while(!notVowel)

	{
		notVowel = false;

		switch(userGuess)
		{
		case 'a' : guess = a;
			notVowel = true;
			break;
		case 'e' : guess = e;
			notVowel = true;
			break;
		case 'i' : guess = i;
			notVowel = true;
			break;
		case 'o' : guess = o;
			notVowel = true;
			break;
		case 'u' : guess = u;
			notVowel = true;
			break;
		default : cout << "Invalid character" << endl;
			cout << "Please enter a lowercase vowel ->";
			cin >> userGuess;
		}
	}

	guess = userGuess;
	cout << "The vowel you chose is: " << guess << endl << endl;
	return (guess);
}
//=============================================================================
bool buy_vowel(int player, int score[], string phrase, string& puzzle, char guess)
{
//Declaring local variables
	string insertChar;
	char secretChar;
	int count, letterPosition = 0, foundAt;
	bool vowelFound = false;
//Calling is vowel to obtain the player's guess
	isvowel(guess);

//Loop to scan array length
	for(count = 0;  (count < phrase.length()) && (phrase[count] != guess); count++)
		continue;

//Checking phrase array for player's guess' letter position 
	while (letterPosition < count && !vowelFound)
	{
		if (phrase[letterPosition] != guess)
		{
			letterPosition++;
		}
		else
		{
			vowelFound = true;
		}
	}
//Indexing where the vowel was found
	foundAt = letterPosition;
//Returning the character from the position that the loop found
	phrase.at(foundAt) = secretChar;
//Changing secretChar into string
	insertChar = secretChar;
//Inserting guessed character into puzzle string
	puzzle.insert(foundAt, insertChar);
//Printing the modified puzzle
	cout << "Here is the current progress: " << endl;
	cout << puzzle << endl;

	return (vowelFound);
}
//=============================================================================

Any help would be GREATLY appreciated. This has become more involved than I thought it would.

Please use code tags. Are you getting any compiler errors? Post them here.

Help with what? Do you really expect us to search through 246 lines of code looking for some unknown problem?

When asking for help, you need to explain in detail what you need help with.

Please use code tags. Are you getting any compiler errors? Post them here.

No, it was compiling fine. I was getting a runtime error that "int players isn't initialized." But, I have since taken care of that issue. However, I haven't set up all of my functions to be called - which will inevitably give me errors.

The problem I am having currently is getting my switch statement for "buy_vowel" to work in line 148.

The function starts on line 206 and the function that buy_vowel calls (isvowel) is right above the buy_vowel function.

When I execute the program and type "b" to buy a vowel, the program ceases to do anything else.. it doesn't close down, or give an error, it just does nothing.

Also, the buy_vowel function should probably work for words with more than just one like vowel. How do I fix that, if it is even correct to begin with?

On line 155:

return(player_turn);

Surely you are trying to return the function itself? You don't appear to have a variable with this name in the function.

On line 155:

return(player_turn);

Surely you are trying to return the function itself? You don't appear to have a variable with this name in the function.

I'm hazy about returning values from functions. I'm confused because I should return a bool, yet, there isn't one declared in the function's parameter itself.

In about an hour from now (time to go to class) I'll repost my code - with code tags (if I can figure out how to do that).

The progress is steadily accumulating.

I'd like to thank everyone who has taken a look at this so far.

You don't HAVE to return a bool if you don't have one declared. Change the type of the function and then change the type of variable that receives the return. You could just use "void" and not have any return if you don't need it.
(If people helped then upvote please :) )

//Wheel of Fortune Program

#include<ctime>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;
//=============================================================================
//Function Prototypes
int spin_wheel();
char isvowel(char guess);
void print_puzzle (string puzzle);
void print_score (int players, int score[]);
void initialize_arrays (string& phrase, string& puzzle);
void printHeading();
bool buy_vowel (int player, int score[], string phrase, string& puzzle);
bool spin (int player, int score[], string phrase, string& puzzle);
bool player_turn (int player, int score[], string phrase, string& puzzle);
bool solve (int player, int score[], string phrase, string& puzzle);
//=============================================================================
//Global Constants
const string STAR = "*";
const int MAX = 14;
const int PHRASE_SIZE = 81;
const int NUM_PLAYERS = 3;
const int VOWEL_COST = 250;
const int BANKRUPT = 0;
const int LOSE_TURN = -1;
const int WHEEL_SIZE = 15;
const int WHEEL[WHEEL_SIZE] = 
	{50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 1000, 1500, 2500,
	BANKRUPT, LOSE_TURN};
//=============================================================================


int main()
{
//Declaring variables
	bool notSolved = false;
	string puzzle, phrase;
	int player = 0;
	int currentPlayer = 0;
	int score[NUM_PLAYERS] = {0, 0, 0};
//Function call to open a data file that contains the phrase
	initialize_arrays(phrase, puzzle);
//Function call to initialize the player's turn
	do 
	{
		player = currentPlayer + 1;
		player = currentPlayer % 3;
	}
	while (notSolved);
	{
	player_turn(player, score, phrase, puzzle);
	}

	return 0;
}

//=============================================================================
//Function call to open file and put it into an array
void initialize_arrays (string& phrase, string& puzzle)
{
	int count;
	ifstream inFile;
	string userInput;

//Error test loop
	cout << "Please enter a file name you wish to open ->";
	cin >> userInput;
	inFile.open(userInput.c_str());

	while(!inFile)
	{
		inFile.clear();
		cout << "Please enter a valid file name->";
		cin >> userInput;
		inFile.open(userInput.c_str());
	}
	
	cout << "Here is your phrase: " << endl;

//Loop to store phrase into array
	
	getline(inFile, phrase);


	for(count = 0; phrase.length() > count; count ++)
	{
		puzzle.insert (count, STAR);
	}	

	cout << puzzle;
	cout << endl << endl;

	inFile.clear();
	inFile.close();
}
//=============================================================================
//Function to print the file's heading
void printHeading()
{
	cout << "Welcome to Wheel of Fortune!" << endl;
}

//=============================================================================
//Function that generates what the wheel spin's value will be
int spin_wheel()
{	
	int spin, luckyNumbers;
	unsigned seed = time(0);
	srand(seed);
	spin = rand() % 14;
	cout << WHEEL[spin] << endl << endl;
	luckyNumbers = WHEEL[spin];

	return(luckyNumbers);
}

//=============================================================================
//Function that prints the phrase array after the puzzle has been solved
void print_puzzle(string phrase)
{
	cout << "CONGRATULATIONS! You've solved the puzzle:" << phrase << endl;
}

//=============================================================================
//Function that directs the players turn
bool player_turn (int player, int score[], string phrase, string& puzzle)
{
//Declaring local variables
	char choice;
	bool validChoice = false;

	cout << "It is player " << player + 1 << "'s turn" << endl;
	cout << "What would you like to do with your turn?" << endl;
	cout << "Here are your options:" << endl;
	cout << "(s)pin the wheel, s(o)lve he puzzle, or (b)uy a vowel" << endl;
	cout << "Type the corresponding lower case letter in () to move on ->";
	cin >> choice;

//Loop to make sure the player entered a valid character to execute
//a function
	while (!validChoice)
	{
		validChoice = false;
		switch (choice)
		{
			case 's': spin (player, score, phrase, puzzle);
				cout << endl;
				validChoice = true;
				break;
			case 'o': solve (player, score, phrase, puzzle);
				cout << endl;
				validChoice = true;
				break;
			case 'b':
				buy_vowel(player, score, phrase, puzzle);
				cout << endl;
				validChoice = true;
				break;
			default : cout << "Please make sure you typed a lower case letter" << endl;
		}
	}
	return(player_turn);
}	

//=============================================================================
//Function to determine if the letter the user selects is a vowel
char isvowel (char guess)
{
//Declaring local variables
	bool notVowel = false;
	enum VOWELS {a, e, i, o, u};
//Error checking loop to make sure player entered a recognized vowel
	while(!notVowel)

	{
		notVowel = false;

		switch(guess)
		{
		case 'a' : guess = a;
			notVowel = true;
			break;
		case 'e' : guess = e;
			notVowel = true;
			break;
		case 'i' : guess = i;
			notVowel = true;
			break;
		case 'o' : guess = o;
			notVowel = true;
			break;
		case 'u' : guess = u;
			notVowel = true;
			break;
		default : cout << "Invalid character" << endl;
			cout << "Please enter a lowercase vowel ->";
			cin >> guess;
		}
	}

	cout << "The vowel you chose is: " << guess << endl << endl;
	return (guess);
}
//=============================================================================
bool buy_vowel(int player, int score[], string phrase, string& puzzle)
{
//Declaring local variables
	string insertChar;
	char secretChar, guess;
	int count, letterPosition = 0, foundAt;
	bool vowelFound = false;
	

//Getting the player's guess
	cout << "Please enter the vowel you wish to buy ";
	cout <<	"as a lowercase character ->";
	cin >> guess;	

	isvowel(guess);

//Loop to scan array length
	for(count = 0;  (count < phrase.length()) && (phrase[count] != guess); count++)
		continue;

//Checking phrase array for player's guess' letter position 
	while (letterPosition < count && !vowelFound)
	{
		if (phrase[letterPosition] != guess)
		{
			letterPosition++;
		}
		else
		{
			vowelFound = true;
		}
	}
//Indexing where the vowel was found
	foundAt = letterPosition;
//Returning the character from the position that the loop found
	secretChar = phrase.at(foundAt);
//Changing secretChar into string
	insertChar = secretChar;
//Inserting guessed character into puzzle string
	puzzle.insert(foundAt, insertChar);
//Deleting the asterik holding the letter's position
	puzzle.erase(foundAt+1, 1);
//Printing the modified puzzle
	cout << "Here is the current progress: " << endl;
	cout << puzzle << endl;

	return (vowelFound);
}
//=============================================================================
bool spin (int player, int score[], string phrase, string& puzzle)

{
spin_wheel();
int count, luckyNumbers, numLetters = 0, puzzleLength = 0;
bool lucky;
char letter;
string foundLetter;

cout << "You've spun " << luckyNumbers << endl;

if (luckyNumbers = 0)
{
	score[player] = 0;
	cout << "BANKRUPT! Better luck next time" << endl;
	lucky = false;
}
	if (luckyNumbers = -1)
	{
		cout << "LOSE TURN! Better luck next time" << endl;
		lucky = false;
	}
	else
	{
		lucky = true;
		cout << "Please enter a lowercase letter you wish to guess ->";
		cin >> letter;
	}

	puzzleLength = phrase.length();
//Loop to scan array for matching letters
	while(lucky)
	{
		
		for(count = 0; count < puzzleLength; count++)
			if(letter == phrase[count])
			{
				lucky = true;
				foundLetter = letter;
				puzzle.insert(count, foundLetter);
				numLetters++;
			}

				if(letter !=phrase[count] && count < puzzleLength)
				{
					lucky = true;
				}
				else (letter !=phrase[count] && count == puzzleLength);
				{
					lucky = false;
				}


	}

	score[player] = numLetters * luckyNumbers;
	
	print_score(player, score);

	return (spin);
}
//=============================================================================
void print_score (int player, int score[])
{
	const string LINE = "========";
	cout << setw(50) << "Here are your current scores: " << endl;
	cout << setw(15) << "PLAYER 1" << setw(15) << "PLAYER 2";
	cout << setw(15) << "PLAYER 3" << endl;
	cout << setw(15) << LINE << setw(15) << LINE << setw(15) << LINE << endl;
	cout << setw(15) << score[0] << score[1] << score[2] << endl << endl;
}

//=============================================================================
bool solve (int player, int score[], string phrase, string& puzzle)
{
	return(solve);
}

Now, something that I am having some trouble with understanding is this. When the function int spin_wheel(); is called in line 263 (int spin_wheel(); function is on line 110) where does the return value go? Does luckyNumbers get assigned that return value after it has been called?

You don't HAVE to return a bool if you don't have one declared. Change the type of the function and then change the type of variable that receives the return. You could just use "void" and not have any return if you don't need it.
(If people helped then upvote please :) )

It's not required that I use a bool type function but, it was one of the prototypes listed on the project write-up, which made me feel like it would be the more useful kind to use... But, if I don't know how to use it, then what use is it?!

Also, would using return (main); on the players_turn function work to keep reiterating turns until the puzzle is solved? Or is that a bad way to go about this?

Post 1:
The return value will currently go no-where. If you want to write the return to the variable (luckyNumbers):

<type> luckyNumbers = spin_wheel();

Post 2:
If you want to repeat turns, then use a loop. Use, say, a while loop, to keep playing until the user presses a certain key or a variable is false or whatever.

Do you go to FSU?

Do you go to FSU?

Yup, and unfortunately this project isn't getting done before midnight =(

I am in the same situation, I guess we're in the same class. Good luck! Mine doesn't look like it will be done on time either.

Join the club. F this project.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.