Guest User

Shopaholic Page 2

a guest
Jul 29th, 2012
48
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #-------------------------------------------------------------------------------
  2. # page 2 of 12
  3. # Shopoholic v 2.0
  4. # code by cmpsr2000
  5. # available exclusively @ rpgrevolution.com/forums
  6. # Released June 25, 2008
  7. #
  8. #-------------------------------------------------------------------------------
  9. class Account < RPG::BaseItem
  10. attr_accessor :balance
  11. attr_accessor :type
  12. attr_accessor :interestRate
  13. #-----------------------------------------------------------------------------
  14. # Creates the account object
  15. # type: The type of account being created:
  16. # 0: Savings
  17. # 1: Checking
  18. # 2: Loan
  19. #-----------------------------------------------------------------------------
  20. def initialize(type)
  21. @type = type
  22. @name = Vocab::BankAccountNames[@type]
  23. @icon_index = Vocab::BankAccountIcons[@type]
  24. @description = Vocab::BankDescriptions[@type]
  25. @balance = 0
  26. @interestRate = 0
  27. end
  28. #-----------------------------------------------------------------------------
  29. # Deposits money into an account. Pays off loans.
  30. # amount: the amount being deposited
  31. #-----------------------------------------------------------------------------
  32. def deposit(amount)
  33. @balance = @type == 2 ? @balance - amount : @balance + amount
  34. end
  35. #-----------------------------------------------------------------------------
  36. # Removes money from the account. You can't withdraw from a loan, only pay it
  37. # off.
  38. # amount: the amount to withdraw from the account
  39. #-----------------------------------------------------------------------------
  40. def withdraw(amount)
  41. @balance = @type == 2 ? @balance : @balance - amount
  42. end
  43. #-----------------------------------------------------------------------------
  44. # Calculates interest for one term on this account.
  45. #-----------------------------------------------------------------------------
  46. def compound
  47. @balance += (@balance * @interestRate).ceil
  48. end
  49. end
RAW Paste Data