savings_account - -- with...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
indexing description: "A basic savings account" author: "Gunnar Gotshalks" date: "$2004 January 30$" revision: "$1.0.0$" class SAVINGS_ACCOUNT c -- A basic savings account that can be opened with an initial balance -- and then deposits and withdrawals can be made. - create open c --======================== feature {NONE} -- creation f open(initial_deposit:REAL) is -- Open a savings account with initial balance of 'initial_deposit' require positive_deposit: initial_deposit >= 0 do balance := initial_deposit ensure open_balance_ok: balance = initial_deposit end --======================== feature -- Access f balance: REAL -- Running total of deposits & withdrawals beginning
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: -- with initial_depost--======================== feature -- Element change f deposit (amount: REAL) is-- Add the amount to the account balance require positive_amount: amount> 0 do balance := balance + amount ensure proper_balance: balance = old balance + amount end withdraw (amount: REAL) is-- Subtract the amount from the account balance require positive_amount: amount > 0 amount <= balance do balance := balance - amount ensure proper_balance: balance = old balance - amount end invariant balance_not_negative: balance >= 0 end -- class SAVINGS_ACCOUNT...
View Full Document

This note was uploaded on 04/03/2010 for the course COMPUTER S CSE 3221 taught by Professor Hui during the Spring '10 term at York University.

Page1 / 2

savings_account - -- with...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online