simulate a pair of dice.

Bin.java 685B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import java.util.*;
  2. /**
  3. * Write a description of class Bin here.
  4. *
  5. * @author (your name)
  6. * @version (a version number or a date)
  7. */
  8. public class Bin
  9. {
  10. private Map<Integer, Integer> entries = new TreeMap();
  11. public Bin(){
  12. entries.put(2,0);
  13. entries.put(3,0);
  14. entries.put(4,0);
  15. entries.put(5,0);
  16. entries.put(6,0);
  17. entries.put(7,0);
  18. entries.put(8,0);
  19. entries.put(9,0);
  20. entries.put(10,0);
  21. entries.put(11,0);
  22. entries.put(12,0);
  23. }
  24. public void counter(Integer key){
  25. Integer count = entries.get(key);
  26. entries.put(key, count +1);
  27. }
  28. public Integer getValue(int key){
  29. return entries.get(key);
  30. }
  31. }