-
Notifications
You must be signed in to change notification settings - Fork 0
/
Simpsons.rb
53 lines (50 loc) · 1.16 KB
/
Simpsons.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
module Simpsons
module Characters
class SimpsonsCharacter
attr_reader :name, :description, :a_list
def initialize(name, description)
@name = name
@description = description
end
def var_return
x = 42
x
end
def simple_return
21
end
def do_something_with_items(list_of_stuff)
newitems = list_of_stuff.collect { |item|
item += item
}
@a_list ||= []
@a_list.concat list_of_stuff
@a_list.uniq!
newitems
end
end
class BartNames
attr_reader :aliases
def initialize(alias_name)
@aliases = {}
@aliases[alias_name] = 1
end
def addAlias(alias_name)
@aliases[alias_name] = (@aliases[alias_name] || 0) + 1
end
end
end
class KWIKEMartProduct
attr_reader :product_name, :product_price
def initialize(product_name, product_price)
@product_name = product_name
@product_price = product_price
end
def increase_cost(increase = 2)
@product_price = @product_price * increase
end
def monitored_by_magic_hat?
true
end
end
end