Constructors and creating values

F-CTOR-V4-2medium

Keep the stay in range

A bed and breakfast creates bookings with default nights, a valid stay and a template of extras.

What needs to change

Repair newBooking so every stay is kept between 1 and 14 nights.

Reproduce

  1. Pipe the sample stays into go run main.go and compare each booking line.

Acceptance criteria

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

Notes

The file contains its imports, readLines, the Booking type and the complete main.

Input: up to 100 "guest nights guests" stays. Guest names are single words, requested nights are signed whole values from -100 to 100, and guest counts are whole values from 0 to 100. Nights below 1 become 1, above 14 become 14. The supplied reader receives valid data.

Sign in to open this exercise

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

Sign in