2013 AP CSA FRQ 2: TokenPass
Topic: Arrays & Circular Movement
Skills: Circular array traversal, random distribution, game simulation
Unit: Unit 4 (Data Collections) (2025-2026 AP CSA)
Points: 9 | Time: ~22 minutes
Part (a)
Write the constructor that initializes the game board.
Solution
public TokenPass(int numPlayers)
{
board = new int[numPlayers];
for (int i = 0; i < board.length; i++)
{
board[i] = (int)(Math.random() * 10) + 1;
}
currentPlayer = (int)(Math.random() * numPlayers);
}Part (b)
Write the distributeCurrentPlayerTokens method.
Solution
public void distributeCurrentPlayerTokens()
{
int tokens = board[currentPlayer];
board[currentPlayer] = 0;
int pos = currentPlayer;
for (int i = 0; i < tokens; i++)
{
pos = (pos + 1) % board.length;
board[pos]++;
}
}Key Concepts
Common Mistakes
Official Resources
Author: Tanner Crow - AP CS Teacher, 11+ years