forked from sordiz/LearnToProgram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoting_booth.rb
More file actions
40 lines (30 loc) · 837 Bytes
/
Copy pathvoting_booth.rb
File metadata and controls
40 lines (30 loc) · 837 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
require_relative 'employee'
class VotingBooth
public
def ask_for_temperatures
employees = Array.new
while(true)
p 'Please enter the desired AC temperature (between 17 and 28, 0 to exit):'
input = gets.chomp.to_i
if (input == 0)
break
end
if (input < 17 || input > 28)
p 'Invalid value.'
next
end
employees.push(create_employee(input))
end
return employees
end
private
def create_employee(temperature)
employee = Employee.new
p 'Please enter the employee name:'
employee.name = gets.chomp
p "Please enter the employee category ('RM', 'SM', 'Dev', 'QA'):"
employee.category = gets.chomp
employee.desired_AC_temperature = temperature
return employee
end
end