Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. package assignmentEight;
  2.  
  3. public class FirstRoll implements Dice {
  4.  
  5. public int sum, i, t, face1 = -1;
  6. public int diceInt, repInt;
  7. public int histogramSum = 0;
  8. public int arraySpots;
  9. public int[][] histogramArray;
  10.  
  11. FirstRoll(int x, int y){
  12. this.diceInt = x;
  13. this.repInt = y;
  14. arraySpots = (diceInt*6)+1;
  15. this.histogramArray = new int[arraySpots][1];
  16. }
  17.  
  18. public void setHistogramZero(){
  19. for(int t=0;t<arraySpots;t++){
  20. System.out.println();
  21. for(int i=0;i<2;i++)
  22. histogramArray[t][i]=0;
  23. System.out.print(histogramArray[t][i]);
  24. }
  25. }
  26.  
  27. public void push(int z){
  28. histogramArray[z][0]= z;
  29. histogramArray[z][1]=histogramArray[z][1]+1;
  30. }
  31.  
  32. public void resetSum(){
  33. histogramSum = 0;
  34. }
  35.  
  36. public int roll(){
  37. face1 = 1+(int)(Math.random()*6);
  38. return face1;
  39. }
  40.  
  41. public void reset(){
  42. face1 = -1;
  43. }
  44.  
  45. public void pringArrayV(){
  46. System.out.println("Vertical Histogram:");
  47. System.out.println();
  48. for(int b=0;b<arraySpots;b++);
  49. }
  50.  
  51. public void printArrayH(){
  52.  
  53. System.out.println();
  54. System.out.println("Horizontal Histogram:");
  55. System.out.println();
  56. for(int b=0;b<arraySpots;b++){
  57. System.out.println(histogramArray[b][0]);
  58. for(int a=0;a<2;a++){
  59. System.out.print("*");
  60. }
  61. System.out.println();
  62. }
  63. }
  64.  
  65. public void getLast(){
  66. int[][] diceArray = new int[repInt][diceInt];
  67.  
  68. System.out.println();
  69. System.out.print("Your last rolls were: ");
  70.  
  71. for(t=0;t<repInt;t++){
  72. resetSum();
  73. for(i=0;i<diceInt;i++){
  74. diceArray[t][i] = roll();
  75. histogramSum += diceArray[t][i];
  76. if(i == diceInt-1){
  77. push(histogramSum);
  78. }
  79.  
  80. if(t == repInt-1){
  81. sum += diceArray[t][i];
  82. System.out.print(diceArray[t][i]+" ");
  83. System.out.print("");
  84.  
  85. if(i == diceInt-1){
  86. System.out.println();
  87. System.out.println("The sum of the last roll is: " + sum);
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement