FunctionRacerProblemsRace

Whose Turn Is It

BeginnerClassesPython, JavaScript, TypeScript, Java, C++

Implement a class TurnTracker for a board game in which the players take turns in a fixed order. Write these methods:

The tests call the methods in sequence and compare every return value. The expected list holds null for the constructor.

Example 1

TurnTracker(["ann","bo","cy"])
whose_turn() returns "ann"
end_turn() returns "bo"
end_turn() returns "cy"
round_number() returns 1
end_turn() returns "ann"
round_number() returns 2
whose_turn() returns "ann"

The turn goes ann, bo, cy, and after cy it wraps back to ann, which starts round 2.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Classes problems