-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflyer_2.rb
60 lines (27 loc) · 884 Bytes
/
flyer_2.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class Flyer
attr_reader :name, :email, :miles_flown
def initialize(name, email, miles_flown)
@name = name
@email = email
@miles_flown = miles_flown
end
def to_s
"#{name} (#{email}): #{miles_flown}"
end
end
promotions = { "United" => 1.5, "Delta" => 2.0, "Lufthansa" => 2.5 }
1.upto(5) do |count|
promotions.each do |key, value|
flyer = Flyer.new("Flyer #{count}", "flyer#{count}@example.com", count)
puts "#{flyer.name.capitalize} - could earn #{flyer.miles_flown * value * 1000} miles by flying with #{key}"
end
end
# puts "Total of miles: #{sum}"
# 1.upto(10) do |count|
# puts "#{count} alligator"
# end
# 1.upto(10) { |n| puts "#{n} alligator" }
# desserts = { "chocolate" => 1.00, "vanilla" => 0.75, "cinnamon" => 1.25 }
# desserts.each do |key, value|
# puts "$#{value*2} for a cup of #{key}"
# end