-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathoop_p2_review.rb
More file actions
81 lines (65 loc) · 1.67 KB
/
oop_p2_review.rb
File metadata and controls
81 lines (65 loc) · 1.67 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
66
67
68
69
70
71
72
73
74
75
76
77
78
# # public methods
# All right! Let's do a little practice with public methods.
# We've set up an Application class in the editor. Add a public method called print_status to Application that puts "All systems go!". Don't forget to use the public keyword!
# class ClassName
# public
# def public_method
# end
# end
class Application
attr_accessor :status
def initialize; end
# Add your method here!
public
def print_status
puts "All systems go!"
end
end
# # private
# Good! Now let's try a private method.
# Below your public method, add a private method called password that returns the super secret password 12345.
# class ClassName
# private
# def private_method
# end
# end
class Application
attr_accessor :status
def initialize; end
# Add your method here!
private
def password
return 12345
end
public
def print_status
puts "All systems go!"
end
end
# # module
# Super. Let's move on to modules!
# Create your own module called Languages in the editor to the right. Include a constant called FAVE and set it equal to a string naming your favorite programming language!
# module ModuleName
# end
# Create your module below!
module Languages
FAVE = "Ruby"
end
# # mixin
# Almost there! Our review wouldn't be complete without a little mixin magic.
# Finally, let's include our Languages module in the Master class (on line 6) so that our favorite language gets printed to the console.
# class ClassName
# include ModuleName
# end
module Languages
FAVE = "Ruby" # This is what you typed before, right? :D
end
class Master
include Languages
def initialize; end
def victory
puts FAVE
end
end
total = Master.new
total.victory