TheIronYard--Orlando / 2015--SUMMER--ROR

Resources and homework for the Summer 2015 Ruby on Rails cohort @TheIronYard--Orlando.
9 stars 6 forks source link

23--jQuery-or-maybe-yQuery--Heidi Roude #158

Open HRoude opened 9 years ago

HRoude commented 9 years ago

jQuery Assignment

HRoude commented 9 years ago

class Student attr_reader :name attr_reader :fives attr_reader :tens attr_reader :twenties

def initialize(name, fives, tens, twenties) @name = name @fives = fives @tens = tens @twenties = twenties end

end ### END of class

def most_money(students) most_money_array = student_hash.max_by{|key,value| value} puts "#{most_money_array[0]} has $#{most_money_array[1]}, which is the most money!" end

return the name of the student with the most money. If all students have the same amount, then "all" should be returned.

phil = Student.new("Phil", 2, 2, 1) 50 cam = Student.new("Cameron", 2, 2, 0) 30
geoff = Student.new("Geoff", 0, 3, 0) 30

phil_total = ((phil.fives) * 5) + ((phil.tens) * 10) + ((phil.twenties) * 20) cam_total = ((cam.fives) * 5) + ((cam.tens) * 10) + ((cam.twenties) * 20) geoff_total = ((geoff.fives) * 5) + ((geoff.tens) * 10) + ((geoff.twenties) * 20)

students = {"Geoff" => geoff_total, "Cam" => cam_total, "Phil" => phil_total}

most_money