simulate a pair of dice.

12345678910111213141516171819202122
  1. public class Dice
  2. {
  3. int numberOfDice;
  4. public Dice(){
  5. numberOfDice = 1;
  6. }
  7. public Dice(int numberOfDice){
  8. this.numberOfDice = numberOfDice;
  9. }
  10. public int tossSum(){
  11. int currentTotal = 0;
  12. for(int i = 0; i <numberOfDice; i++){
  13. currentTotal += (int)Math.ceil(Math.random()*6);
  14. }
  15. return currentTotal;
  16. }
  17. }