c# · level 3 check

a concurrent order processor.

Time to ship a real tool: an order processor. Each line typed is one order, written `customer,item,quantity,price`, like `ana,mug,2,4.50`. Every line is handled as its own task on the thread pool, and a sorted report comes out at the end, identical on every run.

Make it robust. `OrderParser.Parse` turns a line into a `Result<Order>`: an order, or the reason it was refused. `int.TryParse` returns `false` instead of crashing, and hands the number back through `out`, much like `ref`. Blank lines are skipped, names ignore capitals, and refused lines are listed by line number.

Tasks finish in any order, so totals go into a `ConcurrentDictionary` and the accepted count uses `Interlocked`. The report sorts customers by total, highest first, then by name. Fill in each `____`, then try it on orders of your own.

Fill in every ____ then run the checks.
  1. 1 It totals each customer's ordersuses: ConcurrentDictionary
  2. 2 It sorts by total, highest first, then by nameuses: LINQ
  3. 3 It refuses bad lines and says whyuses: pattern matching
  4. 4 It ignores capitals, spaces and blank linesuses: edge cases
  5. 5 It copes with a flood of orders at onceuses: Interlocked
  6. 6 It says so when there is nothing to douses: edge cases

Take as long as you like and try as many times as you want.