Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Urna {
- public static void main(String[] args) {
- double y = Math.random();
- public Urna() { c = 0; }
- public Urna(Color c) { c = y; }
- private int n_blancas, n_negras;
- private double c;
- // double Math.random() generates a number between 0 and 1
- Urna blanca = new Urna(0);
- Urna negra = new Urna(1);
- public void introducirBola(Color c) {
- if (c == blanca) {
- n_blancas += 1;
- }3
- else if (c == negra) {
- n_negras += 1;
- }
- }
- public Color sacarBola() {
- c = double Math.random();
- if (c == blanca) {
- n_blancas -= 1;
- }
- else if (c == negra) {
- n_negras -= 1;
- }
- return Color;
- }
- public boolean estaVacia {
- if (totalBolas() == 0)
- return True;
- }
- public int totalBolas() {
- return n_negras + n_blancas;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement