









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Software Engineering
Here are the operations we shall specify:
Price ∆VendingMachine item? : PROD price? : IN cost′^ = cost ⊕ {item? 7 → price?} stock′^ = stock float′^ = float
Success rep! : REPORT rep! = ‘Okay’
RestockOp ∆VendingMachine new? : bag PROG rep! : REPORT cost′^ = cost float′^ = float (stock′^ = stock ] new? ∧ rep! = ‘Okay’) ∨ (¬(dom new? ⊆ dom cost) ∧ stock′^ = stock ∧ rep! = ‘Some goods are not priced’)
sum : bag COIN → IN is available, which takes a bag of coins and calculates how much is in the bag. For example, given a bag containing 7 × 2 p, and 3 × 5 p coins, sum{ 2 7 → 7 , 5 7 → 3 } = (2 × 7) + (5 × 3) = 14 + 15 = 29pence
Buy ∆VendingMachine in?, out! : bag COIN item? : PROD item? in stock sum(in?) ≥ cost(item?) out! v float sum(in?) = sum(out!) + cost(item?) stock′^ ] {item? 7 → 1 } = stock float′^ ] out? = float ] in? cost′^ = cost