-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.rb
41 lines (35 loc) · 1.14 KB
/
app.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
# require 'io/console'
require 'tty-prompt'
require_relative 'classes/user'
require_relative 'classes/medication'
#Initialize the user and their medicine
marge = User.new("Marge")
marge.add_medication(Panadol.new).add_medication(Asprin.new).add_medication(Cough_Syrup.new)
def check_pin(user)
# check that the user has credentials to access the programm
clear
puts "Hello #{user.name}"
user.enter_pin
end
def main_menu(user)
currently_using = true
while currently_using
selection = TTY::Prompt.new.select("Please select from the following", ["Take Medication", "Your Medication", "History", "Exit"], cycle: true, marker: '>', echo: false)
case selection
when 'History'
user.print_history
when 'Your Medication'
user.print_medication
when 'Take Medication'
user.take_medication
when "Exit"
clear
puts "Have a lovely day, #{user.name}"
currently_using = false
else
puts "Ooops, something went wrong"
end
end
end
check_pin(marge)
main_menu(marge)