Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Items;
- import Actions.EmptyMove;
- import Actions.FillMove;
- import Actions.Move;
- import Actions.PourMove;
- import Interface.Main;
- import java.util.ArrayList;
- import java.util.List;
- public class Configuration implements Move{
- public List<Bottle> bottles;
- public Bottle selectedBottle;
- /**
- * Constructor: Take a list of bottle to initiate the configuration
- * @param bottles
- */
- public Configuration(List<Bottle> bottles) {
- this.bottles = bottles;
- Main.configList.add(this);
- }
- /**
- * Equals: test if a configuration is equal to another one
- * @param config
- * @return
- */
- public boolean equals(Configuration config) {
- if (this.bottles.size() == config.bottles.size()) {
- for (Bottle a : this.bottles) {
- for (Bottle b : config.bottles) {
- if (!b.isEquals(a)) {
- return false;
- }
- }
- }return true;
- }return false;
- }
- public String getIndexName(Bottle bottle) {
- return bottle.getName();
- }
- public List<Bottle> getBottleList(){ return bottles; }
- /**
- * Select one bottle
- * @param bottle
- * @return
- */
- public void selectBottle(Bottle bottle) { this.selectedBottle = bottle; }
- /**
- * Return the bootle on which we do the action
- * @return
- */
- public Bottle activeBootle() {return this.selectedBottle; }
- public int indexBootle() {return bottles.indexOf(activeBootle()); }
- public List<Move> possibleMoves() {
- List<Move> possibleList = new ArrayList<>();
- Configuration active = (Main.configList.get(-1));
- if (active.selectedBottle.isEmpty()) {
- Move toFill = new FillMove(this.getBottleList());
- possibleList.add(toFill);
- } else {
- Move toEmpty = new EmptyMove(this.getBottleList());
- possibleList.add(toEmpty);
- if () {
- Move toPour = new PourMove(this.getBottleList());
- possibleList.add(toPour);
- }
- }
- return possibleList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement