-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_03.rb
More file actions
37 lines (28 loc) · 660 Bytes
/
Copy path04_03.rb
File metadata and controls
37 lines (28 loc) · 660 Bytes
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
def visual_space
puts "-------------------"
end
def titlecase name
name = name.gsub(/\w+/) do |word|
word.capitalize
end
name
end
def get_name name_position
puts "What's your #{name_position} name?"
input = gets.chomp
input = titlecase input
visual_space
input
end
puts "Hi"
firstname = get_name "first"
middlename = get_name "middle"
lastname = get_name "last"
fullname = "#{firstname} #{middlename} #{lastname}"
puts "Hi #{fullname}"
visual_space
puts "#{firstname}, What's your favourite number?"
fav_number = gets.chomp
new_fav_number = fav_number.to_i + 1
visual_space
puts "I think your new favourite number should be #{new_fav_number}"