From 5bfaca953d6d89ceadff0ba57f487be12805f490 Mon Sep 17 00:00:00 2001 From: Ana Piedrahita Date: Sun, 19 Jun 2016 17:07:23 -0400 Subject: [PATCH] admin done --- admin.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/admin.rb b/admin.rb index 94762f2..0c67f8c 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(singed_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" and admin == "no" + puts("You can see all the pages!") + elsif singed_in == "no" and admin == "no" + 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("Have you paid your bills?") + #store their answer in a variable +user_paid = gets.strip.to_i + #ask the user if they have cancelled a deal (yes/no) +puts("Have you cancelled a deal?") + #store their answer in a variable +user_candelled = gets.strip.to_i + #ask the user if they are an admin (yes/no) +puts("Are you an admin?") + #store their answer in a variable +user_admin = gets.strip.to_i + #ask the user if they are signed in (yes/no) +puts("Are you signed in?") + #store their answer in a variable +user_signed_in = gets.strip.to_i + +user_permission(user_signed_in, user_admin,user_paid,user_candelled) #call the function!!