Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();// Random p = p(100);
- string returnValue = Convert.ToString(RandomNumber(0, 100));
- // label1.Text = returnValue;
- int guess;
- guess = 1;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- public int RandomNumber(int min, int max)
- {
- Random random = new Random();
- return random.Next(min, max);
- }
- private void button1_Click(int returnvalue,int guess, object sender, EventArgs e)
- {
- if (Convert.ToInt32(textBox1.Text) < returnvalue)
- {
- label2.Text = ("Too Low! Try Again!");
- label2.Visible = true;
- button1.Visible = false;
- button2.Visible = true;
- guess++;
- }
- if (Convert.ToInt32(textBox1.Text) > returnvalue)
- {
- label2.Text = ("Too High! Try Again!");
- label2.Visible = true;
- button1.Visible = false;
- button2.Visible = true;
- guess++;
- }
- if (Convert.ToInt32(textBox1.Text) == returnvalue)
- {
- label2.Text = ("Correct! It took you {0} guesses.");//add in guess variable
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- label2.Visible = false;
- button2.Visible = false;
- button1.Visible = true;
- textBox1.Text = ("");
- }
- }
- }
Add Comment
Please, Sign In to add comment