Call frames and the call stack

F-FRAMES-V4-3hard

Count each desk on its own

The service-counter model has an arrival helper and receipt helpers. First keep the next queue number across arrivals. Then use the receipt call chain to locate a wrong product argument: the catalog prices apple at 2, pear at 4 and plum at 3; purchases multiply by quantity and refunds return one unit’s price. Finally replay interleaved arrivals at independent counters, each starting at 1.

What needs to change

Repair nextTicket so each desk numbers its own visitors.

Reproduce

  1. Use go run on the three-visitor queue and compare the line for ben with the expected stdout.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

The file contains its imports, readRows, a package counter, nextTicket and main.

Input: a desk name and a visitor’s name on each line.

The supplied replays use well-formed rows and single-word names. Receipt products are in the catalog, quantities are nonnegative integers, and counts and totals fit the selected numeric types.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in