Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Latest commit

 

History

History
47 lines (31 loc) · 1.03 KB

File metadata and controls

47 lines (31 loc) · 1.03 KB

In this exercise you're working at a pizza place that delivers to customers.

You offer three types of pizzas:

  • Margherita: $7
  • Caprese: $9
  • Formaggio: $10

Customers can also choose two additional options for a small additional fee:

  1. Extra sauce: $1
  2. Extra toppings: $2

When customers place and order, an additional fee is added if they only order one or two pizzas:

  • 1 pizza: $3
  • 2 pizzas: $2

You have three tasks, each of which will work with pizzas and their price.

1. Define the pizza types and options

Define the Pizza discriminated union to represent the pizza types and the two additional options that can be added to a pizza:

  • Margherita
  • Caprese
  • Formaggio
  • ExtraSauce
  • ExtraToppings

2. Calculate the price of pizza

Implement the pizzaPrice function to calculate a pizza's price:

pizzaPrice Caprese
// => 9

3. Calculate the price of an order

Implement the orderPrice function to calculate a pizza order's price:

orderPrice [Margherita; Formaggio]
// => 19