Advertisement
Crenox

Lottery Java Program

Jan 8th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. // Sammy Samkough
  2. // Lottery
  3. // Spec: Use a Lottery object to simulate a 6 / 49 Lottery – that is, a 6 number lottery with numbers ranging from 1 to 49
  4. // with no duplicates.
  5.  
  6. public class LotteryArray
  7. {
  8. private int[] inputNums;
  9. private int[] winNums;
  10.  
  11. public LotteryArray()
  12. {
  13.  
  14. }
  15.  
  16. public LotteryArray(int[] num)
  17. {
  18. inputNums = new int[6];
  19. winNums = new int[6];
  20. num = inputNums;
  21. }
  22.  
  23. // generating 6 random values
  24. public void setNumbers()
  25. {
  26. for (int i = 1; i < 6; i++)
  27. {
  28. winNums[i] = (int) (Math.random() * 49) + 1;
  29. }
  30.  
  31. if (inputNums == winNums)
  32. {
  33. System.out.println("YOU WON!");
  34. }
  35. else
  36. {
  37. System.out.println("You lost!");
  38. }
  39. }
  40.  
  41. // to check for duplications in the inputted numbers
  42. public boolean hasDups (boolean valid)
  43. {
  44. if (inputNums == inputNums)
  45. {
  46. return false;
  47. }
  48. else
  49. {
  50. return true;
  51. }
  52. }
  53.  
  54. public String toString()
  55. {
  56. String result = "";
  57.  
  58. return result;
  59. }
  60. }
  61. -------------------------------------------------------------------------------------------------------------------------------
  62. // Sammy Samkough
  63. // Lottery
  64. // Spec: Use a Lottery object to simulate a 6 / 49 Lottery – that is, a 6 number lottery with numbers ranging from 1 to 49 with
  65. // no duplicates.
  66.  
  67. import java.util.Collections;
  68. import java.util.List;
  69. import java.util.ArrayList;
  70.  
  71. public class LotteryArrayList
  72. {
  73. public LotteryArrayList()
  74. {
  75.  
  76. }
  77. }
  78. -------------------------------------------------------------------------------------------------------------------------------
  79. // Sammy Samkough
  80. // Lottery
  81. // Spec: Use a Lottery object to simulate a 6 / 49 Lottery – that is, a 6 number lottery with numbers ranging from 1 to 49 with
  82. // no duplicates.
  83.  
  84. import java.util.Collections;
  85. import java.util.List;
  86. import java.util.ArrayList;
  87. import java.util.Scanner;
  88.  
  89. public class LotteryClient
  90. {
  91. public static void main(String args[])
  92. {
  93. Scanner sc = new Scanner(System.in);
  94. LotteryArray l1 = new LotteryArray();
  95. }
  96. }
  97. /*
  98. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement