CSC/ECE 517 Fall 2011/ch2 2e kt: Difference between revisions
Jump to navigation
Jump to search
Line 14: | Line 14: | ||
def deposit(amount) | def deposit(amount) | ||
@balance += | @balance += amount | ||
end | end | ||
def addinterest(rate) | def addinterest(rate) | ||
@balance *= (1 + | @balance *= (1 + rate) | ||
end | end | ||
Revision as of 15:12, 17 September 2011
Ruby Testing Frameworks
Demo Code
class Account1 @balance @name attr_accessor :balance attr_accessor :name def initialize(amount) @balance = amount end def deposit(amount) @balance += amount end
def addinterest(rate) @balance *= (1 + rate) end def withdrawal(amount) @balance -= amount end
def hasName() return @name != nil end end