import UIKit enum VendingMachineError: Error { case invalidSelection //选择无效 case insufficientFunds(coinsNeeded: Int) //金额不足 case outOfStock //缺货 } struct Item { var price: Int var count: Int } class VendingMachine { var inventory = [ , count: ), , co…