FunctionRacerProblemsRace

Coffee Stamp Cards

EasyClassesPython, JavaScript, TypeScript, Java, C++

Implement a class StampCards for a coffee shop: a customer gets one stamp for each drink they pay for, and once they have goal stamps their next drink is free. 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

StampCards(2)
buy("kim") returns false
buy("kim") returns false
buy("kim") returns true
buy("lee") returns false
stamps_of("kim") returns 0
buy("lee") returns false
count_free() returns 1
get_top_customer() returns "kim"

kim pays for two drinks, which earns two stamps, so the third drink is free and the stamps start over. In total kim has bought 3 drinks and lee 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