-
Notifications
You must be signed in to change notification settings - Fork 12
/
more_functions.rb
54 lines (43 loc) · 1.41 KB
/
more_functions.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
54
# Returns a * b + a + b
#
# multiply_and_sum( 1, 2) #=> 5
# multiply_and_sum( 3, 4) #=> 19
# multiply_and_sum(-1, 2) #=> -1
#
def multiply_and_sum(a, b)
end
# Says hello, defaulting to 'Hello World!'
#
# hello('Tom') #=> "Hello Tom!"
# hello #=> "Hello World!"
#
def hello(name)
end
# Writes a sentence explaining what happens when you integer divide a by b
# [You'll need to look back at / and % from the first ruby session].
#
# explain_integer_divide( 8, 4) #=> "8 divided by 4 is 2 remainder 0"
# explain_integer_divide( 1, 5) #=> "1 divided by 5 is 0 remainder 1"
# explain_integer_divide(33, 7) #=> "33 divided by 7 is 4 remainder 5"
#
def explain_integer_divide(a, b)
end
# Sums an array. If given a multiplier, multiplies the result
#
# sum([1, 2, 3]) #=> 6
# sum([4, 5, 6], -1) #=> -15
#
def sum(array)
end
# Describes the result of a football match
#
# describe_result('Man U', 'Arsenal', 0, 0) #=> "Man U drew with Arsenal, 0 - 0"
# describe_result('Chelsea', 'Man City', 1, 0) #=> "Chelsea beat Man City, 1 - 0"
# describe_result('Chelsea', 'Man City', 0, 2) #=> "Man City beat Chelsea, 2 - 0"
# describe_result('Tottenham', 'Man City', 1, 5) #=> "Man City thrashed Tottenham, 5 - 1"
#
# [A thrashing is where one team beats another by 3 or more goals]
#
def describe_result(team1, team2, score1, score2)
end
# You'll need to write your own test for this in spec/describe_result_spec.rb