Skip to content

Instantly share code, notes, and snippets.

@jasondown
Created December 23, 2021 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasondown/25daecfb1a24c5120552dbf382ee83c4 to your computer and use it in GitHub Desktop.
Save jasondown/25daecfb1a24c5120552dbf382ee83c4 to your computer and use it in GitHub Desktop.
// test
let p = Printer(System.Console.Out.WriteLine)
let vm = VendingMachine(3, p)
let cust = HungryCustomer(vm, 1, p)
cust.Order()
cust.Order()
cust.Order()
// fsi:
// Customer 1 is still hungry and orders another
// Vend item to customer 1
// New stock: 2
// Customer 1 is still hungry and orders another
// Vend item to customer 1
// New stock: 1
// Customer 1 is still hungry and orders another
// Vend item to customer 1
// New stock: 0
cust.Order()
cust.Order()
// fsi:
// Request for customer 1 will be fulfilled after machine is restocked
// Request for customer 1 will be fulfilled after machine is restocked
cust.Done()
// fsi:
// Customer 1 is getting full, so stops ordering
vm.Restock(5)
// fsi:
// Restocking with 5
// Current stock: 5
// Vend item to customer 1
// New stock: 4
// Vend item to customer 1
// New stock: 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment