# A bank to deposit all you have, but with the lack of withdrawal - what a pity.
class Bank
attr :tresor
attr :name
attr :unit
# ctor.
# [name] name of the bank
# [unit] what is this tresor good for.
def initialize(name, unit)
@tresor = 0
@name = name
@unit = unit
end
# To deposit some units.
# [amount] amount as Fixnum
def deposit(amount)
raise if amount<0
@tresor += amount
puts " #{amount} #{@unit}'s deposited. #{@name} has now #{@tresor} #{@unit}'s."
end
# A collective deposition. A list of amounts is deposited in one slide.
# [amounts] an array of amounts
def collective_deposit(amounts)
amounts.each { |amount|
deposit(amount)
}
end
end
syntax highlighted by Code2HTML, v. 0.9.1