Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public class Urna {
  2. public static void main(String[] args) {
  3.  
  4. double y = Math.random();
  5. public Urna() { c = 0; }
  6. public Urna(Color c) { c = y; }
  7. private int n_blancas, n_negras;
  8. private double c;
  9.  
  10. // double Math.random() generates a number between 0 and 1
  11.  
  12. Urna blanca = new Urna(0);
  13. Urna negra = new Urna(1);
  14.  
  15.  
  16. public void introducirBola(Color c) {
  17. if (c == blanca) {
  18. n_blancas += 1;
  19. }3
  20. else if (c == negra) {
  21. n_negras += 1;
  22. }
  23. }
  24.  
  25. public Color sacarBola() {
  26. c = double Math.random();
  27. if (c == blanca) {
  28. n_blancas -= 1;
  29. }
  30. else if (c == negra) {
  31. n_negras -= 1;
  32. }
  33. return Color;
  34. }
  35.  
  36. public boolean estaVacia {
  37. if (totalBolas() == 0)
  38. return True;
  39. }
  40.  
  41. public int totalBolas() {
  42. return n_negras + n_blancas;
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement