From 9f520bfb7412a0ec54cad425ab6802ee358ec70d Mon Sep 17 00:00:00 2001 From: Rachel Goldfarb Date: Sun, 19 Jun 2016 16:41:24 -0400 Subject: [PATCH 1/2] all set with the admin exercise --- admin.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/admin.rb b/admin.rb index 94762f2..33bb028 100644 --- a/admin.rb +++ b/admin.rb @@ -12,22 +12,51 @@ #if the user is signed in but they are not an admin, show "you can see all the pages!" #if the user is not signed in, show "you can't see any of the pages, please sign in!" +def user_permission(signed_in, admin, paid, cancelled) + if (paid == "no" or cancelled == "yes") + puts("Go away!") + elsif (signed_in == "yes" and admin == "yes") + puts("You can see and change all the pages!") + elsif (signed_in == "yes") + puts("You can see all the pages!") + else + puts("You can't see any of the pages, please sign in!") + end +end + #ask the user if they pay their bills (yes/no) +puts("Do you pay your bills? Input yes or no.") + #store their answer in a variable +user_paid = gets.strip + #ask the user if they have cancelled a deal (yes/no) +puts("Have you cancelled a deal? Input yes or no.") + #store their answer in a variable +user_cancelled = gets.strip + #ask the user if they are an admin (yes/no) +puts("Are you an admin? Input yes or no.") + #store their answer in a variable +user_admin = gets.strip + #ask the user if they are signed in (yes/no) +puts("Are you signed in? Input yes or no.") + #store their answer in a variable +user_signed_in = gets.strip #call the function!! + +user_permission(user_signed_in, user_admin, user_paid, user_cancelled) From 719d017a76d77a9b170f603ba349baad71a3e56a Mon Sep 17 00:00:00 2001 From: Rachel Goldfarb Date: Sun, 19 Jun 2016 16:53:34 -0400 Subject: [PATCH 2/2] added the .downcase method --- admin.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/admin.rb b/admin.rb index 33bb028..166f96d 100644 --- a/admin.rb +++ b/admin.rb @@ -30,7 +30,7 @@ def user_permission(signed_in, admin, paid, cancelled) #store their answer in a variable -user_paid = gets.strip +user_paid = gets.strip.downcase #ask the user if they have cancelled a deal (yes/no) @@ -38,7 +38,7 @@ def user_permission(signed_in, admin, paid, cancelled) #store their answer in a variable -user_cancelled = gets.strip +user_cancelled = gets.strip.downcase #ask the user if they are an admin (yes/no) @@ -46,7 +46,7 @@ def user_permission(signed_in, admin, paid, cancelled) #store their answer in a variable -user_admin = gets.strip +user_admin = gets.strip.downcase #ask the user if they are signed in (yes/no) @@ -54,7 +54,7 @@ def user_permission(signed_in, admin, paid, cancelled) #store their answer in a variable -user_signed_in = gets.strip +user_signed_in = gets.strip.downcase #call the function!!