-
-
Save jasondown/ef01722b94cc9676ec8168ec2b51bb5b 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
// test | |
let consolePrinter = Printer(System.Console.Out.WriteLine) | |
let vm = VendingMachine(3, consolePrinter) | |
consolePrinter.Print(sprintf $"Current stock: {vm.GetStock()}") | |
// fsi: | |
// Current stock: 3 | |
let custId1 = 1 | |
let custId2 = 2 | |
vm.BuyItem(custId1) | |
// fsi: | |
// Vend item to customer 1 | |
// New stock: 2 | |
vm.BuyItem(custId2) | |
// fsi: | |
// Vend item to customer 2 | |
// New stock: 1 | |
vm.BuyItem(custId1) | |
// fsi: | |
// Vend item to customer 1 | |
// New stock: 0 | |
vm.BuyItem(custId2) | |
// fsi: | |
// Request for customer 2 will be fulfilled after machine is restocked | |
vm.BuyItem(custId1) | |
// fsi: | |
// Request for customer 1 will be fulfilled after machine is restocked | |
vm.Restock(3) | |
// fsi: | |
// Restocking with 3 | |
// Current stock: 3 | |
// Vend item to customer 2 | |
// New stock: 2 | |
// Vend item to customer 2 | |
// New stock: 1 | |
vm.Restock(7) | |
// fsi: | |
// Restocking with 7 | |
// Current stock: 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment