Guest User

Untitled

a guest
Apr 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();// Random p = p(100);
  17. string returnValue = Convert.ToString(RandomNumber(0, 100));
  18. // label1.Text = returnValue;
  19. int guess;
  20. guess = 1;
  21. }
  22.  
  23. private void Form1_Load(object sender, EventArgs e)
  24. {
  25.  
  26. }
  27. public int RandomNumber(int min, int max)
  28. {
  29. Random random = new Random();
  30. return random.Next(min, max);
  31. }
  32.  
  33. private void label1_Click(object sender, EventArgs e)
  34. {
  35. //label1.Text = ;
  36. }
  37.  
  38. private void button1_Click(object sender, EventArgs e)
  39. {
  40.  
  41.  
  42. if (Convert.ToInt32(textBox1.Text) < returnvalue)
  43. {
  44. label2.Text = ("Too Low! Try Again!");
  45. label2.Visible = true;
  46. button1.Visible = false;
  47. button2.Visible = true;
  48. guess++;
  49. }
  50. if (Convert.ToInt32(textBox1.Text) > returnvalue)
  51. { label2.Text = ("Too High! Try Again!");
  52. label2.Visible = true;
  53. button1.Visible = false;
  54. button2.Visible = true;
  55. guess++;
  56. }
  57. if (Convert.ToInt32(textBox1.Text) == returnvalue)
  58. {
  59. label2.Text = ("Correct! It took you {0} guesses.", guess);
  60. }
  61. }
  62.  
  63. private void button2_Click(object sender, EventArgs e)
  64. {
  65. label2.Visible = false;
  66. button2.Visible = false;
  67. button1.Visible = true;
  68. textBox1.Text = ("");
  69. }
  70. }
  71. }
Add Comment
Please, Sign In to add comment