-
-
Save jasondown/0b643a8f7e165a2fbcc2ebfb9e3f2451 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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