Class: Investment

Inherits:
Object
  • Object
show all
Defined in:
lib/investment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#jahreObject

Returns the value of attribute jahre.



2
3
4
# File 'lib/investment.rb', line 2

def jahre
  @jahre
end

#jahresbeitragObject

Returns the value of attribute jahresbeitrag.



2
3
4
# File 'lib/investment.rb', line 2

def jahresbeitrag
  @jahresbeitrag
end

#kapitelanwuchsObject

Returns the value of attribute kapitelanwuchs.



2
3
4
# File 'lib/investment.rb', line 2

def kapitelanwuchs
  @kapitelanwuchs
end

#verzinsungObject

Returns the value of attribute verzinsung.



2
3
4
# File 'lib/investment.rb', line 2

def verzinsung
  @verzinsung
end