Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package assignmentEight;
- public class FirstRoll implements Dice {
- public int sum, i, t, face1 = -1;
- public int diceInt, repInt;
- public int histogramSum = 0;
- public int arraySpots;
- public int[][] histogramArray;
- FirstRoll(int x, int y){
- this.diceInt = x;
- this.repInt = y;
- arraySpots = (diceInt*6)+1;
- this.histogramArray = new int[arraySpots][1];
- }
- public void setHistogramZero(){
- for(int t=0;t<arraySpots;t++){
- System.out.println();
- for(int i=0;i<2;i++)
- histogramArray[t][i]=0;
- System.out.print(histogramArray[t][i]);
- }
- }
- public void push(int z){
- histogramArray[z][0]= z;
- histogramArray[z][1]=histogramArray[z][1]+1;
- }
- public void resetSum(){
- histogramSum = 0;
- }
- public int roll(){
- face1 = 1+(int)(Math.random()*6);
- return face1;
- }
- public void reset(){
- face1 = -1;
- }
- public void pringArrayV(){
- System.out.println("Vertical Histogram:");
- System.out.println();
- for(int b=0;b<arraySpots;b++);
- }
- public void printArrayH(){
- System.out.println();
- System.out.println("Horizontal Histogram:");
- System.out.println();
- for(int b=0;b<arraySpots;b++){
- System.out.println(histogramArray[b][0]);
- for(int a=0;a<2;a++){
- System.out.print("*");
- }
- System.out.println();
- }
- }
- public void getLast(){
- int[][] diceArray = new int[repInt][diceInt];
- System.out.println();
- System.out.print("Your last rolls were: ");
- for(t=0;t<repInt;t++){
- resetSum();
- for(i=0;i<diceInt;i++){
- diceArray[t][i] = roll();
- histogramSum += diceArray[t][i];
- if(i == diceInt-1){
- push(histogramSum);
- }
- if(t == repInt-1){
- sum += diceArray[t][i];
- System.out.print(diceArray[t][i]+" ");
- System.out.print("");
- if(i == diceInt-1){
- System.out.println();
- System.out.println("The sum of the last roll is: " + sum);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement