Skip to content

Instantly share code, notes, and snippets.

@jasondown
Last active December 23, 2021 19:53
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/0b643a8f7e165a2fbcc2ebfb9e3f2451 to your computer and use it in GitHub Desktop.
Save jasondown/0b643a8f7e165a2fbcc2ebfb9e3f2451 to your computer and use it in GitHub Desktop.
let startOrdering (cust : HungryCustomer) (delaySeconds : int) = async {
for _ in 1 .. 10 do
do cust.Order()
do! Async.Sleep(delaySeconds*1000)
return cust.Done()
}
let outputs text =
System.IO.File.AppendAllText("c:\\temp\\vending-machine.txt", text + System.Environment.NewLine)
System.Console.Out.WriteLine(text)
let printer = Printer(outputs)
let vm = VendingMachine(5, printer)
let showCurrentStock() = printer.Print(sprintf $"Request current stock: {vm.GetStock()}")
let cust1 = HungryCustomer(vm, 1, printer)
let cust2 = HungryCustomer(vm, 2, printer)
let cust3 = HungryCustomer(vm, 3, printer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment