CSC/ECE 517 Fall 2011/ch2 2e kt

From Expertiza_Wiki
Revision as of 15:41, 17 September 2011 by Khheiss (talk | contribs) (→‎Demo Code)
Jump to navigation Jump to search

Ruby Testing Frameworks

Demo Code

 class Account
   @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
 end