Looking for help Guess game
Started by flawkstawker, Feb 16 2009 03:45 PM
3 replies to this topic
#1
Posted 16 February 2009 - 03:45 PM
OK so I'm pretty new to programming and I have made only a few basic programs so far with out too much trouble. The one I'm working on now is giving me trouble though. I have no clue how to make it so i can reset my guess game. I have attached my code in a .txt file any help or tips on design would be awesome.
|
|
|
#2
Posted 18 February 2009 - 01:03 AM
this is code not in a file
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
for (int i = 0; i < score.Length; i++)
score[i] = r.Next(10) + 1;// sets random array values.
}
int[] score = new int[2];// made 2 ints in the array on purpose so I can complicate the game later + practice in declaring.
Random r = new Random();// only way i know how to make a random set of numbers.
private void button1_Click(object sender, EventArgs e)
{
int textBox = int.Parse(textBox1.Text);
if (textBox > score[0])
MessageBox.Show("too high");
else MessageBox.Show("No");// there will be more conditions later after Current problem is solved. Would it be better to use a switch statement?
}
private void Form1_Load(object sender, EventArgs e)// not sure how or why this is hear.
{
}
private void button2_Click(object sender, EventArgs e)//maybe for score to or a reset button
{
}
}
}
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
for (int i = 0; i < score.Length; i++)
score[i] = r.Next(10) + 1;// sets random array values.
}
int[] score = new int[2];// made 2 ints in the array on purpose so I can complicate the game later + practice in declaring.
Random r = new Random();// only way i know how to make a random set of numbers.
private void button1_Click(object sender, EventArgs e)
{
int textBox = int.Parse(textBox1.Text);
if (textBox > score[0])
MessageBox.Show("too high");
else MessageBox.Show("No");// there will be more conditions later after Current problem is solved. Would it be better to use a switch statement?
}
private void Form1_Load(object sender, EventArgs e)// not sure how or why this is hear.
{
}
private void button2_Click(object sender, EventArgs e)//maybe for score to or a reset button
{
}
}
}
#3
Posted 18 February 2009 - 04:12 PM
i am a newbie but i would like to ask you a question, so other experts may jump in and get interested.
what kind of guess game? what is the rule?
and plus, as time goes on, my skill improves, i can code a similar program on my own so i can see how well my level will be
and also will help others too :]
what kind of guess game? what is the rule?
and plus, as time goes on, my skill improves, i can code a similar program on my own so i can see how well my level will be
and also will help others too :]
#4
Posted 18 February 2009 - 08:53 PM
essentially this game makes a random number (actually 2 but im not using the one yet) 1- 10 and based on the users guess/input it will show a hint or tell you that you got it right. Kinda like a hot cold guessing game.


Sign In
Create Account


Back to top









