Interfaces, traits, and type classes

F-IFACE-V4-2medium

Accept only real coupons

A hotel bill applies room discounts, accepts coupons and counts the rooms booked.

What needs to change

Repair charge so bills with no code or an unknown code still work.

Reproduce

  1. Pipe the sample rooms and codes into go run main.go and compare the total line.

Acceptance criteria

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

Notes

The file contains its imports, readLines, the Discounter interface, Coupon, lookup and the complete main.

Input: up to 100 whitespace-delimited "room price [code]" records. Prices are decimal whole units from 0 to 100; a coupon may exceed its price. The supplied reader receives valid fields.

Sign in to open this exercise

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

Sign in