以下のIncommentsクラスのオブジェクトを動的に作成できるようにしてほしい。つまり、プログラムを起動して、ユーザーが好きなだけ収入を入力できるようにし、すべて収入クラスのインスタンスとして保存したいと考えています。
def prompt
puts "> "
end
class Incomes
def initialize(aName, aAmount, aCOLA)
@name = aName
@amount = aAmount
@COLA = aCOLA
end
end
def addIncome
puts "What is the company name?"
prompt
aName = gets.chomp
puts "What is the monthly amount?"
aAmount = gets.chomp
puts "What is the cost of living adjustment?"
aCOLA = gets.chomp
end
#Now I want to be able to loop back through addIncome and create as many objects as the
#user wants. Perhaps there's a better way to store this type of data?