/* * Similar to makeSureValInRange function except it is meant to return * more than one values of valid user input via LinkedList and it will * not return unless all of the input is valid * @param1 scanner object * @param2 lowerbound int * @param3 upperbound int * @param4 String that represents the entity we are entering the values for */ public static LinkedList<Integer> makeSureValInRange2( Scanner scan, int lowerbound, int upperbound, String inputFor) { assert (lowerbound <= upperbound); LinkedList<Integer> list = new LinkedList<Integer>(); System.out.println( SearchCriteria.prioritySetUpString( SearchCriteria.StringEnum.SELECT_CRITERIA, inputFor)); // prints the options to the user int value = scan.nextInt(); if (valInRange(lowerbound, upperbound, value)) { list.add(value); // If the first inputted is in range then we add more values boolean done = false; int i = lowerbound; while (!done && i < upperbound) { // keep looking for input until user enters a duplicate value // or the LinkedList of input is full value = scan.nextInt(); if (!list.contains(value) && valInRange(lowerbound, upperbound, value)) list.add(value); else done = true; i++; } return list; } else { // If the first value intered is not valid, then we return a null, which means that // we use default values (all values within range) System.out.println( SearchCriteria.prioritySetUpString(SearchCriteria.StringEnum.DEFAULT, inputFor)); return null; } }