public boolean isLocationFree(String position) { return (boxPositionStep != null && boxPositionStep.getInput().equals(position)) || (box.isValidPosition(position) && isColumnNonZero(position) && box.isFreePosition(position) && !occupiedLocations.contains(position)); }
public boolean isLocationFree(String position) { return (boxPositionStep != null && boxPositionStep.getInput().equals(position)) || (box.isValidPosition(position) && isColumnNonZero(position) && box.isFreePosition(position)); }
@Override public void processInput(BoxPositionProgressStep step) { if (isLocationFree(step.getInput())) { boxPositionStep = step; } else if (!box.isValidPosition(step.getInput())) { error = String.format("The Box '%s' does not have a position '%s'", box.getAlias(), step.getInput()); } else if (!box.isFreePosition(step.getInput())) { error = String.format("The position '%s' is already occupied", step.getInput()); } }
@Override public void processInput(BoxPositionProgressStep step) { if (isLocationFree(step.getInput())) { boxPositionStep = step; occupiedLocations.add(getPosition()); } else if (!box.isValidPosition(step.getInput()) || !isColumnNonZero(step.getInput())) { error = String.format("The Box '%s' does not have a position '%s'", box.getAlias(), step.getInput()); } else if (!box.isFreePosition(step.getInput()) || occupiedLocations.contains(step.getInput())) { error = String.format("The position '%s' is already occupied", step.getInput()); } }