Skip to content

Instantly share code, notes, and snippets.

@mmmries mmmries/goals.rb
Created Sep 28, 2015

Embed
What would you like to do?
Example Programming Problem
class Goal
attr_accessor :name, :total_amount, :amount_saved_so_far, :predicted_to_complete_at
def initialize(name, total_amount, amount_saved_so_far)
self.name = name
self.total_amount = total_amount
self.amount_saved_so_far = amount_saved_so_far
end
end
def predict_goal_completion(monthly_amount_towards_goals, goals)
# Your Job
# assign the predicted_to_complete_at attribute for each goal
end
goals = [
Goal.new("Eurupe Trip", 10_000.00, 0.0),
Goal.new("Payoff Car", 18_384.13, 4_631.22),
Goal.new("Sweet Shoes", 450.00, 0.0)
]
predict_goal_completion(378.10, goals)
goals.each do |goal|
puts "#{goal.name} will be completed on #{goal.predicted_to_complete_at}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.