-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobot.rb
More file actions
44 lines (34 loc) · 674 Bytes
/
robot.rb
File metadata and controls
44 lines (34 loc) · 674 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
38
39
40
41
42
43
44
#Robot - Jumpstart warmup #6
class Robot
attr_accessor :name, :mac_address
def initialize
@name = name_robot
@mac_address = rand(100_000_000_000_000..281_474_976_710_656)
end
def letter_array
("A".."Z").map {|l| l.upcase}
end
def number_array
("1".."9").map {|n| n.upcase}
end
def name_robot
"#{letter_array.sample}#{letter_array.sample}#{number_array.sample}#{number_array.sample}#{number_array.sample}"
end
def reset
@name = name_robot
end
end
puts "Robot #1"
a = Robot.new
p a.name
p a.name
p a.name
p a.mac_address
puts "Robot #2"
b = Robot.new
p b.name
p b.name
p b.name
b.reset
p b.name
p b.mac_address