|
1 | 1 | require 'pry' |
2 | 2 |
|
3 | | -#you run a site that offers a matching service between vendors selling laptops and customers |
4 | | -#..looking to purchase; you charge a fee to be listed as a vendor |
5 | | -#your site's users must sign in and if they are an admin they are able to make changes to the site |
| 3 | +def user_permission |
6 | 4 |
|
7 | | -######################################################## |
| 5 | +puts "did you pay your bills? (yes/no)" |
| 6 | +paid = gets.strip |
8 | 7 |
|
9 | | -#write a function "user_permission" that accepts four parameters: signed_in, admin, paid, and canceled |
| 8 | +puts "did you cancel" |
| 9 | +canceled = gets.strip |
10 | 10 |
|
11 | | -#ask the user if they pay their bills (yes/no) |
12 | | -#store their answer in a variable |
| 11 | +puts "are you an admin" |
| 12 | +admin = gets.strip |
13 | 13 |
|
14 | | -#ask the user if they have canceled a deal (yes/no) |
15 | | -#store their answer in a variable |
| 14 | +puts "are you signed in" |
| 15 | +signed_in = gets.strip |
16 | 16 |
|
17 | | -#ask the user if they are an admin (yes/no) |
18 | | -#store their answer in a variable |
19 | 17 |
|
20 | | -#ask the user if they are signed in (yes/no) |
21 | | -#store their answer in a variable |
| 18 | +if paid == "no" or canceled == "yes" |
| 19 | + puts "go away" |
22 | 20 |
|
23 | | -#if the user doesn't pay their bills or has canceled a deal, show "go away!" |
24 | | -#if the user is signed in and they are an admin, show "you can see see and change all the pages!" |
25 | | -#if you user is signed in but they are not an admin, show "you can see all the pages!" |
26 | | -#if the user is not signed in, show "you can't see any of the pages, please sign in!" |
27 | 21 |
|
| 22 | +elsif signed_in == "yes" and admin == "yes" |
| 23 | + puts "you can see and change all the pages" |
| 24 | + |
| 25 | + |
| 26 | +elsif signed_in == "yes" and admin == "no" |
| 27 | + puts "you can see all the pages" |
| 28 | + |
| 29 | +elsif signed_in == "no" |
| 30 | + puts "you can't see any of the pages, please sign in" |
| 31 | +else |
| 32 | + "sorry charlie" |
| 33 | +end |
| 34 | +end |
| 35 | +user_permission |
28 | 36 |
|
29 | 37 |
|
30 | 38 | # call the function |
0 commit comments