@Test public void testGetIndexes() { Assert.assertNull(PokerHelper.getIndexes(new Character[]{'3', '4', '5', '6', '7', '8'}, pokers)); Assert.assertNotNull(PokerHelper.getIndexes(new Character[]{}, new ArrayList<>())); Assert.assertEquals(0,PokerHelper.getIndexes(new Character[]{}, new ArrayList<>()).length); }
public static int[] getIndexes(Character[] options, List<Poker> pokers) { List<Poker> copyList = new ArrayList<>(pokers.size()); copyList.addAll(pokers); int[] indexes = new int[options.length]; for(int index = 0; index < options.length; index ++) { char option = options[index]; boolean isTarget = false; for(int pi = 0; pi < copyList.size(); pi ++) { Poker poker = copyList.get(pi); if(poker != null) { if(Arrays.asList(poker.getLevel().getAlias()).contains(option)) { isTarget = true; indexes[index] = pi + 1; copyList.set(pi, null); break; } } } if(! isTarget) { return null; } } Arrays.sort(indexes); return indexes; }
PokerHelper { public static int[] getIndexes(Character[] options, List<Poker> pokers) { List<Poker> copyList = new ArrayList<>(pokers.size()); copyList.addAll(pokers); int[] indexes = new int[options.length]; for(int index = 0; index < options.length; index ++) { char option = options[index]; boolean isTarget = false; for(int pi = 0; pi < copyList.size(); pi ++) { Poker poker = copyList.get(pi); if(poker != null) { if(Arrays.asList(poker.getLevel().getAlias()).contains(option)) { isTarget = true; indexes[index] = pi + 1; copyList.set(pi, null); break; } } } if(! isTarget) { return null; } } Arrays.sort(indexes); return indexes; } }
PokerHelper { public static int[] getIndexes(Character[] options, List<Poker> pokers) { List<Poker> copyList = new ArrayList<>(pokers.size()); copyList.addAll(pokers); int[] indexes = new int[options.length]; for(int index = 0; index < options.length; index ++) { char option = options[index]; boolean isTarget = false; for(int pi = 0; pi < copyList.size(); pi ++) { Poker poker = copyList.get(pi); if(poker != null) { if(Arrays.asList(poker.getLevel().getAlias()).contains(option)) { isTarget = true; indexes[index] = pi + 1; copyList.set(pi, null); break; } } } if(! isTarget) { return null; } } Arrays.sort(indexes); return indexes; }  }
PokerHelper { public static int[] getIndexes(Character[] options, List<Poker> pokers) { List<Poker> copyList = new ArrayList<>(pokers.size()); copyList.addAll(pokers); int[] indexes = new int[options.length]; for(int index = 0; index < options.length; index ++) { char option = options[index]; boolean isTarget = false; for(int pi = 0; pi < copyList.size(); pi ++) { Poker poker = copyList.get(pi); if(poker != null) { if(Arrays.asList(poker.getLevel().getAlias()).contains(option)) { isTarget = true; indexes[index] = pi + 1; copyList.set(pi, null); break; } } } if(! isTarget) { return null; } } Arrays.sort(indexes); return indexes; }  static void sortPoker(List<Poker> pokers); static int[] getIndexes(Character[] options, List<Poker> pokers); static boolean checkPokerIndex(int[] indexes, List<Poker> pokers); static PokerSell checkPokerType(List<Poker> pokers); static int parseScore(SellType sellType, int level); static List<Poker> getPoker(int[] indexes, List<Poker> pokers); static boolean comparePoker(List<Poker> pres, List<Poker> currents); static List<List<Poker>> distributePoker(); static String printPoker(List<Poker> pokers); static String textOnlyNoType(List<Poker> pokers); static int parsePokerColligationScore(List<Poker> pokers); static List<PokerSell> parsePokerSells(List<Poker> pokers); }
PokerHelper { public static int[] getIndexes(Character[] options, List<Poker> pokers) { List<Poker> copyList = new ArrayList<>(pokers.size()); copyList.addAll(pokers); int[] indexes = new int[options.length]; for(int index = 0; index < options.length; index ++) { char option = options[index]; boolean isTarget = false; for(int pi = 0; pi < copyList.size(); pi ++) { Poker poker = copyList.get(pi); if(poker != null) { if(Arrays.asList(poker.getLevel().getAlias()).contains(option)) { isTarget = true; indexes[index] = pi + 1; copyList.set(pi, null); break; } } } if(! isTarget) { return null; } } Arrays.sort(indexes); return indexes; }  static void sortPoker(List<Poker> pokers); static int[] getIndexes(Character[] options, List<Poker> pokers); static boolean checkPokerIndex(int[] indexes, List<Poker> pokers); static PokerSell checkPokerType(List<Poker> pokers); static int parseScore(SellType sellType, int level); static List<Poker> getPoker(int[] indexes, List<Poker> pokers); static boolean comparePoker(List<Poker> pres, List<Poker> currents); static List<List<Poker>> distributePoker(); static String printPoker(List<Poker> pokers); static String textOnlyNoType(List<Poker> pokers); static int parsePokerColligationScore(List<Poker> pokers); static List<PokerSell> parsePokerSells(List<Poker> pokers); static int pokerPrinterType; static int totalPrinters; }