ruby · level 2 check

an expense tracker that saves JSON.

Time to build something you could really use: an expense tracker. You type commands like `add coffee food 3.50`, and it keeps every expense in a file called `expenses.json`, so nothing is lost when the program stops.

It brings the whole level together. Each expense is an `Expense` object with readers, `to_h` and `to_s`. Amounts are kept as whole pence, and categories in small letters, so `Food` and `food` land in one group. Every `add` loads the JSON, adds the new expense and saves it again. `list`, `total` and `report` read the file back, and `json` shows exactly what was saved.

Bad input must never crash it. `Float(text)` works like `Integer`, but for decimals, and raises the same kind of error. A wrong amount, or an `add` with missing pieces, raises your own `BadEntry` error, and the tracker rescues it with a friendly message. Fill in each `____`, run it, then try your own commands, one per line.

Fill in every ____ then run the checks.
  1. 1 It saves each expense and lists ituses: files
  2. 2 It stores the expenses as JSONuses: JSON
  3. 3 It totals in pounds and penceuses: formatting
  4. 4 It reports each category, whatever the capitalsuses: Enumerable
  5. 5 It rescues bad input without crashinguses: errors
  6. 6 It skips blank lines and unknown commandsuses: decisions

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