This project should be done in C# using Visual Studio - Windows Forms. This is a
ID: 3776308 • Letter: T
Question
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
form1 designer:
namespace Wheel_Of_Fortune
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.labelLetters = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.textBox6 = new System.Windows.Forms.TextBox();
this.textBox7 = new System.Windows.Forms.TextBox();
this.textBox8 = new System.Windows.Forms.TextBox();
this.textBox9 = new System.Windows.Forms.TextBox();
this.textBox10 = new System.Windows.Forms.TextBox();
this.textBox11 = new System.Windows.Forms.TextBox();
this.textBox12 = new System.Windows.Forms.TextBox();
this.textBox13 = new System.Windows.Forms.TextBox();
this.textBox14 = new System.Windows.Forms.TextBox();
this.textBox15 = new System.Windows.Forms.TextBox();
this.buttonSpin = new System.Windows.Forms.Button();
this.buttonSolve = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.textBoxP1 = new System.Windows.Forms.TextBox();
this.textBoxP2 = new System.Windows.Forms.TextBox();
this.textBoxP3 = new System.Windows.Forms.TextBox();
this.labelPrompt = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(68, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(91, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Available Letters :";
//
// labelLetters
//
this.labelLetters.AutoSize = true;
this.labelLetters.Location = new System.Drawing.Point(179, 13);
this.labelLetters.Name = "labelLetters";
this.labelLetters.Size = new System.Drawing.Size(35, 13);
this.labelLetters.TabIndex = 1;
this.labelLetters.Text = "label2";
//
// panel1
//
this.panel1.Controls.Add(this.textBox15);
this.panel1.Controls.Add(this.textBox14);
this.panel1.Controls.Add(this.textBox13);
this.panel1.Controls.Add(this.textBox12);
this.panel1.Controls.Add(this.textBox11);
this.panel1.Controls.Add(this.textBox10);
this.panel1.Controls.Add(this.textBox9);
this.panel1.Controls.Add(this.textBox8);
this.panel1.Controls.Add(this.textBox7);
this.panel1.Controls.Add(this.textBox6);
this.panel1.Controls.Add(this.textBox5);
this.panel1.Controls.Add(this.textBox4);
this.panel1.Controls.Add(this.textBox3);
this.panel1.Controls.Add(this.textBox2);
this.panel1.Controls.Add(this.textBox1);
this.panel1.Controls.Add(this.label2);
this.panel1.Location = new System.Drawing.Point(41, 51);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(548, 67);
this.panel1.TabIndex = 2;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(15, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(38, 13);
this.label2.TabIndex = 0;
this.label2.Text = "Puzzle";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(18, 28);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(24, 20);
this.textBox1.TabIndex = 1;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(48, 28);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(24, 20);
this.textBox2.TabIndex = 2;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(78, 28);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(24, 20);
this.textBox3.TabIndex = 3;
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(108, 28);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(24, 20);
this.textBox4.TabIndex = 4;
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(162, 28);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(24, 20);
this.textBox5.TabIndex = 5;
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(192, 28);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(24, 20);
this.textBox6.TabIndex = 6;
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(245, 28);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(24, 20);
this.textBox7.TabIndex = 7;
//
// textBox8
//
this.textBox8.Location = new System.Drawing.Point(275, 28);
this.textBox8.Name = "textBox8";
this.textBox8.Size = new System.Drawing.Size(24, 20);
this.textBox8.TabIndex = 8;
//
// textBox9
//
this.textBox9.Location = new System.Drawing.Point(305, 28);
this.textBox9.Name = "textBox9";
this.textBox9.Size = new System.Drawing.Size(24, 20);
this.textBox9.TabIndex = 9;
//
// textBox10
//
this.textBox10.Location = new System.Drawing.Point(360, 28);
this.textBox10.Name = "textBox10";
this.textBox10.Size = new System.Drawing.Size(24, 20);
this.textBox10.TabIndex = 10;
//
// textBox11
//
this.textBox11.Location = new System.Drawing.Point(390, 28);
this.textBox11.Name = "textBox11";
this.textBox11.Size = new System.Drawing.Size(24, 20);
this.textBox11.TabIndex = 11;
//
// textBox12
//
this.textBox12.Location = new System.Drawing.Point(420, 28);
this.textBox12.Name = "textBox12";
this.textBox12.Size = new System.Drawing.Size(24, 20);
this.textBox12.TabIndex = 12;
//
// textBox13
//
this.textBox13.Location = new System.Drawing.Point(450, 28);
this.textBox13.Name = "textBox13";
this.textBox13.Size = new System.Drawing.Size(24, 20);
this.textBox13.TabIndex = 13;
//
// textBox14
//
this.textBox14.Location = new System.Drawing.Point(480, 28);
this.textBox14.Name = "textBox14";
this.textBox14.Size = new System.Drawing.Size(24, 20);
this.textBox14.TabIndex = 14;
//
// textBox15
//
this.textBox15.Location = new System.Drawing.Point(510, 28);
this.textBox15.Name = "textBox15";
this.textBox15.Size = new System.Drawing.Size(24, 20);
this.textBox15.TabIndex = 15;
//
// buttonSpin
//
this.buttonSpin.Location = new System.Drawing.Point(83, 150);
this.buttonSpin.Name = "buttonSpin";
this.buttonSpin.Size = new System.Drawing.Size(75, 23);
this.buttonSpin.TabIndex = 3;
this.buttonSpin.Text = "Spin";
this.buttonSpin.UseVisualStyleBackColor = true;
this.buttonSpin.Click += new System.EventHandler(this.buttonSpin_Click);
//
// buttonSolve
//
this.buttonSolve.Location = new System.Drawing.Point(367, 149);
this.buttonSolve.Name = "buttonSolve";
this.buttonSolve.Size = new System.Drawing.Size(75, 23);
this.buttonSolve.TabIndex = 4;
this.buttonSolve.Text = "Solve";
this.buttonSolve.UseVisualStyleBackColor = true;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(71, 232);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(45, 13);
this.label3.TabIndex = 5;
this.label3.Text = "Player 1";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(244, 232);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(45, 13);
this.label4.TabIndex = 6;
this.label4.Text = "Player 2";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(389, 232);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(45, 13);
this.label5.TabIndex = 7;
this.label5.Text = "Player 3";
//
// textBoxP1
//
this.textBoxP1.Location = new System.Drawing.Point(71, 268);
this.textBoxP1.Name = "textBoxP1";
this.textBoxP1.Size = new System.Drawing.Size(100, 20);
this.textBoxP1.TabIndex = 8;
//
// textBoxP2
//
this.textBoxP2.Location = new System.Drawing.Point(233, 267);
this.textBoxP2.Name = "textBoxP2";
this.textBoxP2.Size = new System.Drawing.Size(100, 20);
this.textBoxP2.TabIndex = 9;
//
// textBoxP3
//
this.textBoxP3.Location = new System.Drawing.Point(379, 268);
this.textBoxP3.Name = "textBoxP3";
this.textBoxP3.Size = new System.Drawing.Size(106, 20);
this.textBoxP3.TabIndex = 10;
//
// labelPrompt
//
this.labelPrompt.AutoSize = true;
this.labelPrompt.Location = new System.Drawing.Point(203, 322);
this.labelPrompt.Name = "labelPrompt";
this.labelPrompt.Size = new System.Drawing.Size(35, 13);
this.labelPrompt.TabIndex = 11;
this.labelPrompt.Text = "label6";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(595, 382);
this.Controls.Add(this.labelPrompt);
this.Controls.Add(this.textBoxP3);
this.Controls.Add(this.textBoxP2);
this.Controls.Add(this.textBoxP1);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.buttonSolve);
this.Controls.Add(this.buttonSpin);
this.Controls.Add(this.panel1);
this.Controls.Add(this.labelLetters);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label labelLetters;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.TextBox textBox15;
private System.Windows.Forms.TextBox textBox14;
private System.Windows.Forms.TextBox textBox13;
private System.Windows.Forms.TextBox textBox12;
private System.Windows.Forms.TextBox textBox11;
private System.Windows.Forms.TextBox textBox10;
private System.Windows.Forms.TextBox textBox9;
private System.Windows.Forms.TextBox textBox8;
private System.Windows.Forms.TextBox textBox7;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button buttonSpin;
private System.Windows.Forms.Button buttonSolve;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBoxP1;
private System.Windows.Forms.TextBox textBoxP2;
private System.Windows.Forms.TextBox textBoxP3;
private System.Windows.Forms.Label labelPrompt;
}
}
code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Wheel_Of_Fortune
{
public partial class Form1 : Form
{
public string availableLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public string puzzle = "backtothefuture";
Dictionary<int, int> spinValues = new Dictionary<int, int>();
int i = 1;
string[] playerAmounts = new string[3] { "$0", "$0", "$0" };
List<TextBox> puzzleBoxes = new List<TextBox>();
public Form1()
{
InitializeComponent();
AddSpinValues();
labelLetters.Text = availableLetters;
textBoxP1.Text = playerAmounts[0];
textBoxP2.Text = playerAmounts[1];
textBoxP3.Text = playerAmounts[2];
if (i > 3) i = 1;
labelPrompt.Text = "Player " + i + " Spin or Solve";
puzzleBoxes.Add(textBox1);
puzzleBoxes.Add(textBox2);
puzzleBoxes.Add(textBox3);
puzzleBoxes.Add(textBox4);
puzzleBoxes.Add(textBox5);
puzzleBoxes.Add(textBox6);
puzzleBoxes.Add(textBox7);
puzzleBoxes.Add(textBox8);
puzzleBoxes.Add(textBox9);
puzzleBoxes.Add(textBox10);
puzzleBoxes.Add(textBox11);
puzzleBoxes.Add(textBox12);
puzzleBoxes.Add(textBox13);
puzzleBoxes.Add(textBox14);
puzzleBoxes.Add(textBox15);
}
private void AddSpinValues()
{
spinValues.Add(1, 100);
spinValues.Add(2, 300);
spinValues.Add(3, 500);
spinValues.Add(4, 700);
spinValues.Add(5, 900);
spinValues.Add(6, 2000);
spinValues.Add(7, 3000);
spinValues.Add(8, 5000);
spinValues.Add(9, -1000);
spinValues.Add(10, 0);
}
private void buttonSpin_Click(object sender, EventArgs e)
{
Random r = new Random();
int number = r.Next(1, 10);
int amountGot = spinValues[number];
char input='0';
Dialog d = new Dialog();
d.labelDialog.Text = "You got " + amountGot + ". Guess the letter !";
if (d.ShowDialog(this) == DialogResult.OK)
{
input = Convert.ToChar(d.textBox1.Text.ToLower());
if (input<'a'||input>'z') d.labelDialog.Text = "Invalid input";
}
else
{
d.labelDialog.Text = "Operation Cancelled";
}
d.Dispose();
if (puzzle.Contains(input.ToString()))
{
int n = puzzle.Count(x => x == input);
playerAmounts[i - 1] = "$" + (Convert.ToInt32(playerAmounts[i - 1].Substring(1)) + (n * amountGot)).ToString();
if (i == 1) textBoxP1.Text = playerAmounts[i - 1];
else if (i==2) textBoxP2.Text = playerAmounts[i - 1];
else textBoxP3.Text = playerAmounts[i - 1];
List<int> indexes = AllIndexesOf(puzzle, input.ToString());
foreach(int x in indexes)
{
puzzleBoxes[x - 1].Text = puzzle[i].ToString();
}
}
else
{
MessageBox.Show("In Correct");
}
i = i++;
availableLetters = availableLetters.Replace(input,' ');
labelLetters.Text = availableLetters;
labelPrompt.Text = "Player " + i + " Spin or Solve";
}
public List<int> AllIndexesOf(string str, string value)
{
if (String.IsNullOrEmpty(value))
throw new ArgumentException("the string to find may not be empty", "value");
List<int> indexes = new List<int>();
for (int index = 0; ; index += value.Length)
{
index = str.IndexOf(value, index);
if (index == -1)
return indexes;
indexes.Add(index);
}
}
}
}
dialog designer:
namespace Wheel_Of_Fortune
{
partial class Dialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelDialog = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// labelDialog
//
this.labelDialog.AutoSize = true;
this.labelDialog.Location = new System.Drawing.Point(63, 13);
this.labelDialog.Name = "labelDialog";
this.labelDialog.Size = new System.Drawing.Size(59, 13);
this.labelDialog.TabIndex = 0;
this.labelDialog.Text = "labelDialog";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(66, 48);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 1;
//
// Dialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(407, 102);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.labelDialog);
this.Name = "Dialog";
this.Text = "Dialog";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
public System.Windows.Forms.Label labelDialog;
public System.Windows.Forms.TextBox textBox1;
}
}
code:
using System.Windows.Forms;
namespace Wheel_Of_Fortune
{
public partial class Dialog : Form
{
public Dialog()
{
InitializeComponent();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.