-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.rb
More file actions
65 lines (47 loc) · 1.01 KB
/
debug.rb
File metadata and controls
65 lines (47 loc) · 1.01 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# change the code. Source code https://www.codepile.net/pile/M5XMAE4x
module AdminPermisson
def edit_users_profile
puts "Admin updated all users profile"
end
end
module BuyerPermission
def buy
puts "Buyer has bought an item"
end
end
class User
def initialize(username, password, ip_address)
@username = username
@password = password
@ip_address = ip_address
end
def change_password=(password)
@password = password
puts "Password changed!"
end
protected
def login
puts "User logged in. IP address: #{@ip_address}"
end
end
class Admin < User
def admin_login
login
end
include AdminPermisson
end
class Buyer < User
def buyer_login
login
end
include BuyerPermission
end
## execute
my_admin = Admin.new('avionuser', 'password', '127.0.0.1')
my_admin.admin_login
my_admin.edit_users_profile
my_admin.change_password = 'new_password'
buyer = Buyer.new('juan', 'password', '127.0.0.1')
buyer.buyer_login
buyer.buy
buyer.change_password = 'new_password'