Exports, visibility, and encapsulation

F-EXPORT-V4-3hard

Refuse an invalid order

The bakery needs a callable adjustment calculator, an independent sorted report and refusal through its order-creation API. Each repair uses a separate focused project.

What needs to change

Repair shop/order.hpp so an order for fewer than one item is refused when it is created.

Reproduce

  1. Use `clang++ -std=c++2c -Wall -Wextra -pedantic main.cpp -o main && ./main` with the Sample stdin. Compare the creation-refusal lines with the expected output.

Acceptance criteria

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

Notes

The project has main.cpp and shop/order.hpp. main reports refused when constructing an Order throws std::invalid_argument.

Input: an item and a quantity on each line.

This project uses the supplied shop module and caller. Inputs are LF/CRLF-delimited records; ordinary ASCII spaces and tabs separate fields. Names are opaque valid UTF-8 tokens of at most 100 bytes, excluding ASCII space, tab, CR and LF. ASCII space/tab/CR framing is removed; other name characters are preserved.

There are at most 50 records. Quantities are signed decimal integers from -100 through 100, with optional sign and leading zeros. Bread costs 3, cake 5, tea 2; any other name costs 0. The supplied reader receives valid input.

Sign in to open this exercise

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

Sign in