Call frames and the call stack

F-FRAMES-V4-2medium

Follow the trace to the caller

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 the receipt function that passes the wrong word to priceOf.

Reproduce

  1. Use go run on the two-line sample, then read the goroutine stack on stderr from the top: which of your functions called priceOf?

Acceptance criteria

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

Notes

The file contains its imports, readRows, the prices map, priceOf, buy, refund and main. priceOf is correct and panics for an unknown product.

Input: buy, a product and a quantity, or refund and a product, 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