simulate a pair of dice.

12345678910111213141516171819202122232425262728
  1. import java.math.*;
  2. import java.util.Map;
  3. /**
  4. * Write a description of class Dice here.
  5. *
  6. * @Mexi Liang
  7. * 06/08/2018
  8. */
  9. public class Dice
  10. {
  11. int numOfDice;
  12. public Dice(Integer n){
  13. numOfDice =n;
  14. }
  15. public Integer tossAndSum(){
  16. int sum =0;
  17. for (int i=1;i<=numOfDice;i++){
  18. sum = sum + (int)(Math.random()*6+1);
  19. }
  20. return sum;
  21. }
  22. }