Rank Rush

Card Rank Counter Arena · based on Code Quest Problem 277
Read the original problem ↗

Arcade Mode: beat the clock, build streaks, earn a certificate. Practice Mode: same rounds, no timer, no pressure.

How to Play

  1. Every round, the table deals you a hand of cards — anywhere from 6 to 22 of them.
  2. The gold bounty card above the table tells you which rank to count that round (a number 2–10, or Jack/Queen/King/Ace).
  3. Count how many cards in the hand match that rank, type the number in the box, and click Lock In (or hit Enter).
  4. You'll see immediately if you were right, then click Next Round → to keep going. There are 12 rounds total.
  5. Arcade Mode: a timer bar counts down each round — answer faster and build a streak for bonus points. Running out of time locks in "no answer" and breaks your streak.
  6. Practice Mode: no timer, no score pressure — same 12 rounds, just count carefully.
  7. After round 12, you'll get a results screen and can print a certificate with your name and stats.
1/12
Round
0
Score
0
Streak
0
Best Streak
Count how many cards are ranked —
Behind the Cards: how would you code this?

Every round on this table is the same task as Problem 277: you're handed a stack of cards and one target rank, and you count matches. That's a single loop with a counter:

int count = 0;
for (int i = 0; i < cards.length; i++) {
    if (cards[i].equals(targetRank)) {
        count++;
    }
}
System.out.println(count);

Two traps worth knowing before you submit real code:

1. Ranks come in as Strings ("2" through "10", or "Jack"/"Queen"/"King"/"Ace") — compare them with .equals(), never ==. String == compares object references, not contents, and it will pass your own quick tests while quietly failing on the judge.

2. The problem gives you multiple test cases per run (a count on line 1, then that many test cases in sequence) — your outer loop needs to read and print once per test case, not just once total.

Sample from the original problem, for reference:

Input:
2
5
2
King
Ace
King
Jack
King
4
2
3
4
5
4

Output:
2
1

Once you've played a few rounds here and trust your counting logic, head to the Code Quest site and submit it for real in Java.

ArrayList Crash Course (for the Codio version)

The Codio skeleton hands you the hand of cards as a List<String> (specifically an ArrayList) instead of a plain array, because you don't know how many cards are coming until you read N from the file. An array needs its size locked in up front; an ArrayList grows as you add to it.

Creating one and adding to it:

List<String> cards = new ArrayList<>();
cards.add("King");
cards.add("5");
cards.add("Jack");

The <String> is the type it holds — this ArrayList only holds Strings. That's exactly what the skeleton does in the reading loop: it starts with an empty list and calls .add() once per card it reads from the file.

Finding out how many items are in it:

int howMany = cards.size();   // 3, not cards.length -- ArrayLists use size(), arrays use .length

Getting one item out by position:

String first = cards.get(0);   // "King" -- indexes still start at 0

Walking through every item (the version you'll actually want here):

// for-each -- reads "for each String c in cards"
for (String c : cards) {
    System.out.println(c);
}

// the equivalent classic for loop, if you'd rather index it
for (int i = 0; i < cards.size(); i++) {
    System.out.println(cards.get(i));
}

Either loop visits every card exactly once, in order. For counting how many match a target rank, the for-each version reads the cleanest: check each c against your target inside the loop, same idea as looping over an array, just with .size() instead of .length and no [i] brackets required.

The one rule that still applies: the items inside are Strings, so compare them with c.equals(targetRank), never c == targetRank — that doesn't change just because the Strings now live inside an ArrayList instead of an array.

That's really all countRank() needs: a for-each loop, an .equals() check, and a counter you increment. If you get stuck, try writing it first as an array version in your head, then translate array.length → list.size() and array[i] → list.get(i).

Certificate of Completion

Rank Rush — Card Rank Counter Arena
Student Name
0
Final Score
0
Best Streak
0/0
Rounds Correct
Arcade
Mode
Based on Lockheed Martin Code Quest Academy Problem 277 — lmcodequestacademy.com/problem/card-rank-counter
Completed