package input; /** * The class handling the parsing of one input. * @author Victor * */ public class Inputs { private static final int numberOfInputs = 8; private static boolean[] tab; public Inputs() { this.tab = new boolean[numberOfInputs]; for(int i = 0; i < numberOfInputs; i ++) { this.tab[i] = false; } } /** * record one input * @param i the integer value corresponding to the tab location */ public void recordOneInput(Button b) { int i = b.toInt(); this.tab[i] = true; } /** * Check if a specific input (for example UP) has been recorded * @param i the integer value corresponding to the input * @return */ public boolean containsInput(Button b) { return this.tab[b.toInt()]; } /** * Check if a number of inputs are contained simultaneously * @param in a number of inputs. Check if those are containes in this * @return true if all inputs of in are also in this */ public boolean containsInputs(Inputs in) { for(int i = 0; i < numberOfInputs; i++) { if(this.tab[i] != in.getInputs()[i]) {return false;} } return true; } /** * Check if a number of inputs are contained simultaneously, in the form of an array of Buttons * @param bs a number of inputs. Check if those are contained in this * @return true if all inputs of in are also in this */ public boolean containsButtonTab(Button[] bs) { for(int i = 0; i < bs.length; i++) { if(!this.containsInput(bs[i])) { return false;} } return true; } public boolean[] getInputs() { return this.tab; } }