Please HELP! I need this by tonight and I am having a major problem. This projec
ID: 3575414 • Letter: P
Question
Please HELP! I need this by tonight and I am having a major problem.
This project should be done in C# using Visual Studio - Windows Forms.
This is a puzzle game of Wheel of Fortune. I need the puzzle to be "Back to the Future", and it should not matter if the player guesses a upper or lowercase letter. If possible I could use step by step instructions for creating the windows form and then entering the code to make the program run. All the requirements for the game will be in pictures below.
The example uses the puzzle "pulp fiction", but again I need my puzzle to be "Back to the Future". Thanks!
You are to create the classic game of Wheel of Fortune. Your application should consist of 3 players, underlines to represent letters in the puzzle, and the available letters. The initial screen should look something like:Explanation / Answer
#include<ctime>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;
//Function Prototypes
private void initialize_arrays(string phrase, string puzzle)
{
int count;
ifstream inFile = new ifstream();
string userInput;
//Error test loop
Console.Write("Please enter a file name you wish to open ->");
userInput = ConsoleInput.ReadToWhiteSpace(true);
inFile.open(userInput);
while (inFile == null)
{
inFile.clear();
Console.Write("Please enter a valid file name->");
userInput = ConsoleInput.ReadToWhiteSpace(true);
inFile.open(userInput);
}
Console.Write("Here is your phrase: ");
Console.Write(" ");
//Loop to store phrase into array
getline(inFile, phrase);
for (count = 0; phrase.Length > count; count++)
{
puzzle = puzzle.Insert(count, STAR);
}
Console.Write(puzzle);
Console.Write(" ");
Console.Write(" ");
inFile.clear();
inFile.close();
}
//Global Constants
private const string STAR = "*";
private const int MAX = 14;
private const int PHRASE_SIZE = 81;
private const int NUM_PLAYERS = 3;
private const int VOWEL_COST = 250;
private const int BANKRUPT = 0;
private const int LOSE_TURN = -1;
private const int WHEEL_SIZE = 15;
private readonly int[] WHEEL = {50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 1000, 1500, 2500, BANKRUPT, LOSE_TURN};
static int Main()
{
//Declaring variables
bool notSolved = false;
string puzzle;
string phrase;
int player = 0;
int currentPlayer = 0;
int[] score = {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;
}
internal static class ConsoleInput
{
private static bool goodLastRead = false;
internal static bool LastReadWasGood
{
get
{
return goodLastRead;
}
}
internal static string ReadToWhiteSpace(bool skipLeadingWhiteSpace)
{
string input = "";
char nextChar;
while (char.IsWhiteSpace(nextChar = (char)System.Console.Read()))
{
//accumulate leading white space if skipLeadingWhiteSpace is false:
if (!skipLeadingWhiteSpace)
input += nextChar;
}
//the first non white space character:
input += nextChar;
//accumulate characters until white space is reached:
while (!char.IsWhiteSpace(nextChar = (char)System.Console.Read()))
{
input += nextChar;
}
goodLastRead = input.Length > 0;
return input;
}
internal static string ScanfRead(string unwantedSequence = null, int maxFieldLength = -1)
{
string input = "";
char nextChar;
if (unwantedSequence != null)
{
nextChar = '';
for (int charIndex = 0; charIndex < unwantedSequence.Length; charIndex++)
{
if (char.IsWhiteSpace(unwantedSequence[charIndex]))
{
//ignore all subsequent white space:
while (char.IsWhiteSpace(nextChar = (char)System.Console.Read()))
{
}
}
else
{
nextChar = (char)System.Console.Read();
if (nextChar != unwantedSequence[charIndex])
return null;
}
}
input = nextChar.ToString();
if (maxFieldLength == 1)
return input;
}
while (!char.IsWhiteSpace(nextChar = (char)System.Console.Read()))
{
input += nextChar;
if (maxFieldLength == input.Length)
return input;
}
return input;
}
}//Function to print the file's heading
private void printHeading()
{
Console.Write("Welcome to Wheel of Fortune!");
Console.Write(" ");
}
//Function that generates what the wheel spin's value will be
private int spin_wheel()
{
int spin;
int luckyNumbers;
uint seed = time(0);
RandomNumbers.Seed(seed);
spin = RandomNumbers.NextNumber() % 14;
Console.Write(WHEEL[spin]);
Console.Write(" ");
Console.Write(" ");
luckyNumbers = WHEEL[spin];
return (luckyNumbers);
}
//Function that prints the phrase array after the puzzle has been solved
private void print_puzzle(string phrase)
{
Console.Write("CONGRATULATIONS! You've solved the puzzle:");
Console.Write(phrase);
Console.Write(" ");
}
//Function that directs the players turn
private bool player_turn(int player, int[] score, string phrase, string puzzle)
{
//Declaring local variables
sbyte choice;
bool validChoice = false;
Console.Write("It is player ");
Console.Write(player + 1);
Console.Write("'s turn");
Console.Write(" ");
Console.Write("What would you like to do with your turn?");
Console.Write(" ");
Console.Write("Here are your options:");
Console.Write(" ");
Console.Write("(s)pin the wheel, s(o)lve the puzzle, or (b)uy a vowel");
Console.Write(" ");
Console.Write("Type the corresponding lower case letter in () to move on ->");
choice = sbyte.Parse(ConsoleInput.ReadToWhiteSpace(true));
//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);
Console.Write(" ");
validChoice = true;
break;
case 'o':
solve(player, score, phrase, puzzle);
Console.Write(" ");
validChoice = true;
break;
case 'b':
buy_vowel(player, score, phrase, puzzle);
Console.Write(" ");
validChoice = true;
break;
default :
Console.Write("Please make sure you typed a lower case letter");
Console.Write(" ");
break;
}
}
return (player_turn);
}
internal static class RandomNumbers
{
private static System.Random r;
internal static int NextNumber()
{
if (r == null)
Seed();
return r.Next();
}
internal static int NextNumber(int ceiling)
{
if (r == null)
Seed();
return r.Next(ceiling);
}
internal static void Seed()
{
r = new System.Random();
}
internal static void Seed(int seed)
{
r = new System.Random(seed);
}
}
internal static class ConsoleInput
{
private static bool goodLastRead = false;
internal static bool LastReadWasGood
{
get
{
return goodLastRead;
}
}
internal static string ReadToWhiteSpace(bool skipLeadingWhiteSpace)
{
string input = "";
char nextChar;
while (char.IsWhiteSpace(nextChar = (char)System.Console.Read()))
{
//accumulate leading white space if skipLeadingWhiteSpace is false:
if (!skipLeadingWhiteSpace)
input += nextChar;
}
//the first non white space character:
input += nextChar;
//accumulate characters until white space is reached:
while (!char.IsWhiteSpace(nextChar = (char)System.Console.Read()))
{
input += nextChar;
}
goodLastRead = input.Length > 0;
return input;
}
internal static string ScanfRead(string unwantedSequence = null, int maxFieldLength = -1)
{
string input = "";
char nextChar;
if (unwantedSequence != null)
{
nextChar = '';
for (int charIndex = 0; charIndex < unwantedSequence.Length; charIndex++)
{
if (char.IsWhiteSpace(unwantedSequence[charIndex]))
{
//ignore all subsequent white space:
while (char.IsWhiteSpace(nextChar = (char)System.Console.Read()))
{
}
}
else
{
//ensure each character matches the expected character in the sequence:
nextChar = (char)System.Console.Read();
if (nextChar != unwantedSequence[charIndex])
return null;
}
}
input = nextChar.ToString();
if (maxFieldLength == 1)
return input;
}
while (!char.IsWhiteSpace(nextChar = (char)System.Console.Read()))
{
input += nextChar;
if (maxFieldLength == input.Length)
return input;
}
return input;
}
}