% $Id: NewBankAccount.oz,v 1.1 2008/04/09 22:31:10 leavens Exp leavens $ \insert 'NewPortObject.oz' fun {NewBankAccount} {NewPortObject state(balance: 0 open: true) fun {$ state(balance: N open: IsOpen) Msg} if {Not IsOpen} then raise notOpen end end case Msg of close then if N==0 then state(balance: N open: false) else raise illegalCloseBalanceNotZero end end [] deposit(Dollars) then state(balance: N+Dollars open: true) [] withdraw(Dollars) then state(balance: N-Dollars open: true) [] inquire(WhatAmt) then WhatAmt=N state(balance: N open: true) end end } end