Class: Investment
- Inherits:
-
Object
- Object
- Investment
- Defined in:
- lib/investment.rb
Instance Attribute Summary collapse
-
#jahre ⇒ Object
Returns the value of attribute jahre.
-
#jahresbeitrag ⇒ Object
Returns the value of attribute jahresbeitrag.
-
#kapitelanwuchs ⇒ Object
Returns the value of attribute kapitelanwuchs.
-
#verzinsung ⇒ Object
Returns the value of attribute verzinsung.
Instance Method Summary collapse
-
#initialize(jahresbeitrag, jahre, verzinsung) ⇒ Investment
constructor
A new instance of Investment.
Constructor Details
#initialize(jahresbeitrag, jahre, verzinsung) ⇒ Investment
Returns a new instance of Investment.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/investment.rb', line 5 def initialize(jahresbeitrag, jahre, verzinsung) @jahresbeitrag = jahresbeitrag @jahre = jahre + 1 @verzinsung = verzinsung @kapitelanwuchs = [] kapital = 0 jahre.times do kapital += kapital/100*verzinsung kapital += jahresbeitrag + jahresbeitrag/100*verzinsung kapitelanwuchs << sprintf("%0.2f", kapital) end end |
Instance Attribute Details
#jahre ⇒ Object
Returns the value of attribute jahre.
2 3 4 |
# File 'lib/investment.rb', line 2 def jahre @jahre end |
#jahresbeitrag ⇒ Object
Returns the value of attribute jahresbeitrag.
2 3 4 |
# File 'lib/investment.rb', line 2 def jahresbeitrag @jahresbeitrag end |
#kapitelanwuchs ⇒ Object
Returns the value of attribute kapitelanwuchs.
2 3 4 |
# File 'lib/investment.rb', line 2 def kapitelanwuchs @kapitelanwuchs end |
#verzinsung ⇒ Object
Returns the value of attribute verzinsung.
2 3 4 |
# File 'lib/investment.rb', line 2 def verzinsung @verzinsung end |