/
subway_methods.rb
53 lines (31 loc) · 2.22 KB
/
subway_methods.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
47
48
49
50
51
52
53
# A subway story
# You hop on the subway at Union Square. As you are waiting for the train you take a look at the subway map. The map is about 21 inches wide and 35 inches tall. Let's write a method to returns the area of the map:
def map_size
"The map is #{21 * 25} square inches"
end
# Now you give it a shot! It takes about 156 seconds to go between stops and you'll be taking the train for 3 stops. Write a method that returns how long your trip will take.
def trip_length
# write your code here
end
# While you are waiting for the train you decide to play a little dice. Create a method called roll that returns a random number between 1 and 6 (feel free to google "how to generate a random number in ruby").
# write your code here
# The train arrives and you hop on. Guess what time it is? It's showtime! There are 23 people on the train and each person gives the dancers 1.5 dollars. Write a method called pay_dancers that returns how much money they made.
# There is one grumpy lady on the train that doesn't like the dancing though. Write a method called stop_dancing that returns a message to the dancers in all caps.
# There is also a really enthusiastic rider who keeps shouting "Everything is awesome!" Write a method called everything_is_awesome that returns one string with "Everything is awesome!" 5 times. (Ruby has a `.times` method that can help you do this. Think about setting up an empty string and adding to it five times)
# You are almost at your stop and you start thinking about how you are going to get home. You have $18 dollars left on your metro card (For those of you not in New York, the price of a metro card is now $2.75). Write a method called remaining_trips that return how many trips you have left.
# Call your methods below:
puts "How big is that subway map?"
# call your method here - like this
puts map_size
puts "This is how long the trip will take"
puts trip_length
puts "While I was waiting I rolled a"
# call your method here
puts "How much money did the train dancers make?"
# call your method here
puts "That lady told the train dancers to"
# call your method here
puts "That guy kept shouting"
# call your method here
puts "This is how many trips I have left on my metrocard"
# call your method here