Engraving
The blacksmith has learned to engrave: names, mottos, anything that customers want to have on their items. The type Order has a new kind, "engrave", with the text to engrave, and the first engraving is already in the order book. Engraving costs engravePrice gold for each character of the text, so Kira's KIRA costs 12 gold, and with her discount, 7.
Run the program and see what TypeScript says. If your code checks the kinds of orders with the exhaustiveness check, TypeScript now shows you every place that doesn't handle engraving yet. Add engraving everywhere, and at the end, print how many orders of each kind there are:
Bruno: forging, Shield (bronze), 20 gold (new customer)
Kira: engraving KIRA, Elven Bow, 7 gold (5 off)
Total: 80 gold
Forging: 2, repairs: 1, sharpening: 1, engraving: 1A tip: a Record whose keys are the kinds of orders is a good place to count them, the way you counted the encounters on Kira's journey in the Modeling Data lesson.
That's the whole project. Your program prices orders of several kinds, finds customers who may not be there and reads properties that may be missing, and when the order book got a new kind of order, TypeScript showed you where the program had to change. In the next lesson, Generics, you'll learn to write functions and types that work with any type, while TypeScript still keeps track of which type it is.
Instructions
Add engraving to the lines of the orders and to the total.
At the end, print how many orders of each kind there are.
Start programming for free
3/3