ace

arraylist for responses1

ace
Jan 23rd, 2010
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.ArrayList;
  3. /**
  4. * Write a description of class RandomTester here.
  5. *
  6. * @author (your name)
  7. * @version (a version number or a date)
  8. */
  9. public class RandomTester
  10. {
  11. // instance variables - replace the example below with your own
  12. private int x;
  13. Random randomGenerator;
  14. Private ArrayList<String> responces;
  15. /**
  16. * Constructor for objects of class RandomTester
  17. */
  18. public RandomTester()
  19. {
  20. // initialise instance variables
  21. x = 0;
  22. randomGenerator = new Random();
  23. responces = new ArrayList<String>();
  24. }
  25.  
  26. /**
  27. * An example of a method - replace this comment with your own
  28. *
  29. * @param y a sample parameter for a method
  30. * @return the sum of x and y
  31. */
  32. public int sampleMethod(int y)
  33. {
  34. // put your code here
  35. return x + y;
  36. }
  37.  
  38. public void printNewRandom()
  39. {
  40. int index = randomGenerator.nextInt();
  41. System.out.println(index);
  42. }
  43.  
  44. public void printMultiRandom(int howMany)
  45. {
  46. int index = 0;
  47. {
  48. while(index < howMany)
  49. {
  50.  
  51. System.out.println(randomGenerator.nextInt());
  52. index++;
  53. }
  54. }
  55. }
  56.  
  57. public int throwDice()
  58. {
  59. int index = randomGenerator.nextInt(6);
  60. {
  61. return index+1;
  62. }
  63. }
  64.  
  65. public String getResponse()
  66. {
  67. int index = randomGenerator.nextInt(3);
  68. {
  69. if (index == 0)
  70. {
  71. return "yes";
  72. }
  73. if(index == 1)
  74. {
  75. return "no";
  76. }
  77. if(index == 2)
  78. {
  79. return "maybe";
  80. }
  81. else
  82. {
  83. return "null";
  84. }
  85. }
  86. }
  87. }
  88.  
Add Comment
Please, Sign In to add comment