-
Notifications
You must be signed in to change notification settings - Fork 0
/
setter-getter.rb
117 lines (73 loc) · 1.37 KB
/
setter-getter.rb
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# make setter & getter
# method1
# require 'pry'
# class Dog
# # attr_reader :name, :breed
# def initialize(name, breed)
# @name = name
# @breed = breed
# end
# def name
# @name
# end
# def breed
# @breed
# end
# end
# doggy = Dog.new("Pug", "German Shepherd")
# binding.pry
# require 'pry'
# class Dog
# attr_reader :name, :breed
# def initialize(name, breed)
# @name = name
# @breed = breed
# end
# end
# doggy = Dog.new("Pug", "German Shepherd")
# binding.pry
# person
# method1
# require 'pry'
# class Person
# def initialize(name, job)
# @name = name
# @job = job
# end
# def name
# @name
# end
# def job
# @job
# end
# end
# bobby = Person.new("Bob", "Software Engineer")
# binding.pry
require 'pry'
# class Person
# #setter method - replace with attr_writer
# def name=(name)
# @name = name
# end
# #getter method replace with attr_reader
# def name
# @name
# end
# end
# bobby = Person.new
# bobby.name = 'bobby'
# # puts bobby.name
class Pet
def initialize(name)
@name = name
end
def name=(name)
@name = name
end
def name
@name
end
end
rabbit = Pet.new("Jabby")
rabbit.name = "Chokola"
binding.pry