Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Check for an 11-pair in the selected cards.
- * @param selectedCards selects a subset of this board. It is list
- * of indexes into this board that are searched
- * to find an 11-pair.
- * @return true if the board entries in selectedCards
- * contain an 11-pair; false otherwise.
- */
- private boolean containsPairSum11(List<Integer> selectedCards) {
- System.out.println(selectedCards);
- /*
- The point is to find every possible combination, and see if that combination sums up to
- be 11
- */
- int counter = 0;
- int counterOther = 0;
- int size = selectedCards.size();
- while(counter < size) {
- while(counterOther < size) {
- int sum = cardAt(selectedCards.get(counter)).pointValue() + cardAt(selectedCards.get(counterOther)).pointValue();
- System.out.println("Sum = " + sum);
- if(sum == 11) {
- int card = selectedCards.get(counter);
- int cardTwo = selectedCards.get(counterOther);
- selectedCards.clear();
- selectedCards.add(card);
- selectedCards.add(cardTwo);
- return true;
- }
- counterOther++;
- }
- counter++;
- counterOther = counter + 1;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement