Handle one failure, pass the other
A garden planner prices hedges from a price list: box costs 4 and yew 6 per metre.
What needs to change
Repair hedgeCost so only an unknown plant is priced as box.
Reproduce
- Use `clang++ -std=c++2c -Wall -Wextra -pedantic main.cpp -o main && ./main` with the sample stdin and compare the bad-length line and allowed fallback cost.
Acceptance criteria
Your review marks · Saved in this browser. Test acceptance is tracked separately.
Notes
The file contains its headers, readRows, UnknownPlant, BadLength, price, hedgeCost and main. price throws BadLength before UnknownPlant.
Input: a hedge name, a plant and a length in metres on each line.
Input contains at most 50 hedge records, one per LF/CRLF line. Ordinary ASCII spaces/tabs separate the three fields; ASCII spaces/tabs/CR frame a line. Blank framed lines are ignored.
Names and plant codes are opaque valid UTF-8 tokens of at most 64 bytes, excluding ASCII space, tab, CR and LF. Names and plant codes also exclude U+0000. Other characters, including BOM and NEL, stay part of the token. A physical line has at most 4096 bytes.
A length is an optional plus or minus followed by ASCII decimal digits, with numeric value from -100 through 100. Leading zeros are allowed. The supplied reader receives valid fields; these are input assumptions, not a validation task.
A length of zero or less fails before plant lookup. For a positive length only an unknown plant uses the box price; known plant prices are unchanged.
Products are integers from -600 through 600, within the native numeric representations used here.