-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.rb
62 lines (58 loc) · 1.19 KB
/
input.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
55
56
57
58
59
60
61
62
require './handle_person'
require './check_person'
require './handle_book'
require './handle_rental'
class Input
def self.list_options(app, input)
puts input
case input
when 1
puts 'List of books'
app.all_book
when 2
puts 'List of person'
app.all_person
else
puts 'Invalid input!'
end
end
def self.check_input_create_people(app)
puts 'Do you want to create a student (1) or a teacher? (2) [Input 1 or 2]'
input = gets.chomp.to_i
case input
when 1
HandlePerson.create_student(app)
when 2
HandlePerson.create_teacher(app)
else
puts 'Invalid input!'
end
end
def self.check_input(app, input)
case input
when 1..2
list_options(app, input)
when 3..5
create_options(app, input)
when 6
CheckPerson.person_info(app)
when 7
puts 'Goodbye!'
raise StopIteration
else
puts "You input #{input}"
end
end
def self.create_options(app, input)
case input
when 3
check_input_create_people(app)
when 4
HandleBook.create_book(app)
when 5
HandleRental.create_rental(app)
else
puts 'Invalid input!'
end
end
end