From d5fb74ab94a2f13988fc3b9ddb211ae6cdb1a32a Mon Sep 17 00:00:00 2001 From: Van Ann Bui Date: Sun, 19 Jun 2016 17:15:07 -0400 Subject: [PATCH] new admin file --- admin.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/admin.rb b/admin.rb index 94762f2..76aa883 100644 --- a/admin.rb +++ b/admin.rb @@ -11,23 +11,52 @@ #if the user is signed in and they are an admin, show "you can see and change all the pages!" #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, canceled) + + if paid == "No" or canceled == "Yes" + puts("go away!") + elsif signed_in == "Yes" and admin == "Yes" + puts("you can see and change all the pages!") + elsif signed_in == "Yes" and admin == "No" + 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? Yes/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 canceled a deal? Yes/No") + #store their answer in a variable +user_canceled = gets.strip + #ask the user if they are an admin (yes/no) +puts("Are you an admin? Yes/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? Yes/No") + #store their answer in a variable +user_signed_in = gets.strip +user_permission(user_signed_in, user_admin, user_paid, user_canceled) #call the function!! +