Guest User

Untitled

a guest
Feb 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7.  
  8. public partial class _Default : System.Web.UI.Page
  9. {
  10. protected void Page_Load(object sender, EventArgs e)
  11. {
  12.  
  13. }
  14.  
  15. public void insertUserNumbers_Click(object sender, EventArgs e)
  16. {
  17. int maxValue = 59;
  18. int minValue = 1;
  19. int maxPowerball = 40;
  20. Random rndU = new Random();
  21. int[] uTempNumbs = new int[6];
  22. for (int i = 0; i < uTempNumbs.Length -1; i++)//Intializes Values First before testing.
  23. {
  24. uTempNumbs[i] = rndU.Next(minValue, maxValue);
  25. }
  26. for (int i = 0; i < uTempNumbs.Length - 1; i++)
  27. {
  28. bool[] uBoolRange = new bool[6];
  29. bool[] uCompareBool = new bool[6];
  30. uBoolRange[i] = IsNumberInRange(uTempNumbs[i], minValue, maxValue);
  31. //rmWinner(uCompareBool, cCompareBool);
  32. if(i > 1)
  33. {
  34. IsNumberDuplicate( i, uTempNumbs );//(temp0, temp1, temp2, temp3, temp4); //(uTempNumbs[i], uTempNumbs[i + 1]);
  35. }
  36.  
  37. //uBoolPball = IsNumberInRange(uTempNumbs[5], minValue, maxPowerball);//Because The Power Ball has a lower limit.
  38. //MessageResults.Text = MessageResults.Text + " In Range?: " + uBoolRange[i] + " Max: " + maxValue + " Min: " + minValue + " something: " + uTempNumbs[i] + "\n";
  39. //int WinMatch = 0;
  40. //WinMatch = normWinner(uTempNumbs, cTempNumbs);
  41. //MessageResults.Text = MessageResults.Text + "Winner ? " + WinMatch.ToString();
  42. if ( uBoolRange[0] == true )
  43. {
  44. txtNumPick0.Text = uTempNumbs[i].ToString();
  45. }
  46. if ( uBoolRange[1] == true )
  47. {
  48. txtNumPick1.Text = uTempNumbs[i].ToString();
  49. }
  50. if ( uBoolRange[2] == true )
  51. {
  52. txtNumPick2.Text = uTempNumbs[i].ToString();
  53. }
  54. if ( uBoolRange[3] == true )
  55. {
  56. txtNumPick3.Text = uTempNumbs[i].ToString();
  57. }
  58. if ( uBoolRange[4] == true )
  59. {
  60. txtNumPick4.Text = uTempNumbs[i].ToString();
  61. }
  62. if ( uBoolRange[5] == true )
  63. {
  64. txtPowPick.Text = uTempNumbs[i].ToString();
  65. }
  66.  
  67. }
  68.  
  69. }
  70.  
  71. protected void btnPlayGame_Click(object sender, EventArgs e)
  72. {
  73.  
  74. int maxValue = 59;
  75. int minValue = 1;
  76. int maxPowerball = 40;
  77. Random rndC = new Random();
  78. int[] cTempNumbs = new int[6];
  79. for (int i = 0; i < cTempNumbs.Length - 1; i++)
  80. {
  81. cTempNumbs[i] = rndC.Next(minValue, maxValue);
  82. }
  83. for (int i = 0; i < cTempNumbs.Length - 1; i++)
  84. {
  85. bool[] cBoolRange = new bool[6];
  86. cBoolRange[i] = IsNumberInRange(cTempNumbs[i], minValue, maxValue);
  87. if (i > 1)
  88. {
  89. IsNumberDuplicate(i, cTempNumbs);//(temp0, temp1, temp2, temp3, temp4); //(uTempNumbs[i], uTempNumbs[i + 1]);
  90. }
  91. //cBoolRange[i] = IsNumberInRange(cTempNumbs[i], minValue, maxValue);
  92. //MessageResults.Text = MessageResults.Text + " In Range?: " + cBoolRange[i] + " Max: " + maxValue + " Min: " + minValue + " something: " + cTempNumbs[i] + "\n";
  93.  
  94. if (cBoolRange[0] == true)
  95. {
  96. lblComPick0.Text = cTempNumbs[0].ToString();
  97. }
  98. if (cBoolRange[1] == true)
  99. {
  100. lblComPick1.Text = cTempNumbs[1].ToString();
  101. }
  102. if (cBoolRange[2] == true)
  103. {
  104. lblComPick2.Text = cTempNumbs[2].ToString();
  105. }
  106. if (cBoolRange[3] == true)
  107. {
  108. lblComPick3.Text = cTempNumbs[3].ToString();
  109. }
  110. if (cBoolRange[4] == true)
  111. {
  112. lblComPick4.Text = cTempNumbs[4].ToString();
  113. }
  114. if (cBoolRange[5] == true)
  115. {
  116. lblComPowPick.Text = cTempNumbs[5].ToString();
  117. }
  118.  
  119.  
  120. }
  121.  
  122.  
  123. // normWinner(uTempNumbs, cTempNumbs);Doesn't recogonize uTempNumbs
  124. }
  125.  
  126.  
  127.  
  128. //if( uTempNumbs[0] == cTempNumbs[0]){
  129.  
  130. //}
  131.  
  132. public Boolean IsNumberInRange(int number, int minValue, int maxValue)
  133. {
  134.  
  135. Boolean returnValue = false;//Default value causes a return no matter what.
  136.  
  137. if (number >= minValue && number <= maxValue) returnValue = true;///by returnValue instead of return.
  138.  
  139. return returnValue;
  140. }
  141.  
  142. public void IsNumberDuplicate( int ipassedin, int[] uTempNumbs)//(int number0, int number1, int number2, int number3, int number4 )
  143. {//Number is i in the for iteration.
  144.  
  145. for (int x = 0; x < ipassedin; x++)//Minus 1 because you don't want to check against itself.
  146. {
  147. MessageResults.Text = "x = " + x + "\t ipassedin = " + ipassedin + "\n";
  148. while (uTempNumbs[x] == uTempNumbs[ipassedin])//number is the latest number in the array.
  149. {//TempNumbs is the array that is being passed in. number is never 0 because of the if( i > 1) Firt comparison is 0 vs 1 in the array uTempNumbs
  150. Random rndU = new Random();
  151. uTempNumbs[ipassedin] = rndU.Next(1, 59);
  152. IsNumberDuplicate( ipassedin, uTempNumbs);
  153. }
  154.  
  155. }
  156.  
  157. }
  158. public void normWinner(int[] uTempNumbs, int[] cTempNumbs)
  159. {
  160. int returnValue = 0;
  161.  
  162. for (int i = 0; i < 6; i++ )
  163. {
  164. for (int j = 0; j < 6; j++ )
  165. {
  166. if (uTempNumbs[i] == cTempNumbs[j])
  167. MessageResults.Text = MessageResults.Text + " Winner: " + uTempNumbs[i];
  168. //uTempNumbs[i] = 0;
  169. //return uTempNumbs[i];//Works but repeats on all numbers.
  170. //returnValue = 0;
  171. //returnValue = uTempNumbs[i];
  172. //return returnValue;//Works but repeats on all numbers.
  173. MessageResults.Text = MessageResults.Text + "Winner ? " + uTempNumbs[i].ToString();
  174.  
  175. }
  176. //return uTempNumbs[i];
  177. //return returnValue;
  178. //uTempNumbs[i] = 0;
  179. //uTempNumbs[1] = 0;
  180. //uTempNumbs[2] = 0;
  181. //uTempNumbs[3] = 0;
  182. //uTempNumbs[4] = 0;
  183.  
  184. //cTempNumbs[i] = 0;
  185. //cTempNumbs[1] = 0;
  186. //cTempNumbs[2] = 0;
  187. //cTempNumbs[3] = 0;
  188. //cTempNumbs[4] = 0;
  189.  
  190. }
  191. //return uTempNumbs[i];//Doesn't exist within it current context.
  192. //return returnValue;
  193.  
  194. }
  195. }
Add Comment
Please, Sign In to add comment