SHARE
TWEET

Untitled

a guest Mar 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Items;
  2. import Actions.EmptyMove;
  3. import Actions.FillMove;
  4. import Actions.Move;
  5. import Actions.PourMove;
  6. import Interface.Main;
  7. import java.util.ArrayList;
  8. import java.util.List;
  9.  
  10. public class Configuration implements Move{
  11.     public List<Bottle> bottles;
  12.     public Bottle selectedBottle;
  13.  
  14.     /**
  15.      * Constructor: Take a list of bottle to initiate the configuration
  16.      * @param bottles
  17.      */
  18.     public Configuration(List<Bottle> bottles) {
  19.         this.bottles = bottles;
  20.         Main.configList.add(this);
  21.     }
  22.  
  23.     /**
  24.      * Equals: test if a configuration is equal to another one
  25.      * @param config
  26.      * @return
  27.      */
  28.     public boolean equals(Configuration config) {
  29.         if (this.bottles.size() == config.bottles.size()) {
  30.             for (Bottle a : this.bottles) {
  31.                 for (Bottle b : config.bottles) {
  32.                     if (!b.isEquals(a)) {
  33.                         return false;
  34.                     }
  35.                 }
  36.             }return true;
  37.         }return false;
  38.     }
  39.  
  40.     public String getIndexName(Bottle bottle) {
  41.         return bottle.getName();
  42.     }
  43.     public List<Bottle> getBottleList(){ return bottles; }
  44.  
  45.     /**
  46.      * Select one bottle
  47.      * @param bottle
  48.      * @return
  49.      */
  50.     public void selectBottle(Bottle bottle) { this.selectedBottle = bottle; }
  51.  
  52.     /**
  53.      * Return the bootle on which we do the action
  54.      * @return
  55.      */
  56.     public Bottle activeBootle() {return this.selectedBottle; }
  57.     public int indexBootle() {return bottles.indexOf(activeBootle()); }
  58.  
  59.     public List<Move> possibleMoves() {
  60.         List<Move> possibleList = new ArrayList<>();
  61.         Configuration active = (Main.configList.get(-1));
  62.        
  63.         if (active.selectedBottle.isEmpty()) {
  64.             Move toFill = new FillMove(this.getBottleList());
  65.             possibleList.add(toFill);
  66.         } else {
  67.             Move toEmpty = new EmptyMove(this.getBottleList());
  68.             possibleList.add(toEmpty);
  69.             if () {
  70.                 Move toPour = new PourMove(this.getBottleList());
  71.                 possibleList.add(toPour);
  72.             }
  73.         }
  74.  
  75.  
  76.         return possibleList;
  77.     }
  78. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top