2020-04-17 16:03:59 +02:00
|
|
|
package main;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
2020-04-21 12:31:59 +02:00
|
|
|
import java.util.List;
|
2020-04-18 19:39:59 +02:00
|
|
|
import java.util.Stack;
|
2020-04-17 16:03:59 +02:00
|
|
|
|
2020-04-18 19:39:59 +02:00
|
|
|
import carte.CartePiochable;
|
|
|
|
|
|
|
|
public class Pioche<T extends Type> {
|
|
|
|
|
|
|
|
private Stack<CartePiochable<T>> cartesPiochables;
|
|
|
|
|
2020-04-21 12:31:59 +02:00
|
|
|
public Pioche(List<CartePiochable<T>> cartesPiochables) {
|
|
|
|
super();
|
|
|
|
this.cartesPiochables = new Stack<CartePiochable<T>>();
|
|
|
|
this.cartesPiochables.addAll(cartesPiochables);
|
|
|
|
melanger();
|
|
|
|
}
|
|
|
|
|
2020-04-18 19:39:59 +02:00
|
|
|
public void melanger()
|
|
|
|
{
|
2020-04-17 16:03:59 +02:00
|
|
|
Collections.shuffle(cartesPiochables);
|
2020-04-18 19:39:59 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 14:10:31 +02:00
|
|
|
public CartePiochable<?> piocher() {
|
2020-04-18 19:39:59 +02:00
|
|
|
return cartesPiochables.pop();
|
2020-04-17 16:03:59 +02:00
|
|
|
}
|
|
|
|
}
|