Skip to content

Instantly share code, notes, and snippets.

@PirosB3
Last active August 29, 2015 14:05
Show Gist options
  • Save PirosB3/aa7878f275c026b69f13 to your computer and use it in GitHub Desktop.
Save PirosB3/aa7878f275c026b69f13 to your computer and use it in GitHub Desktop.
class Person
attr_accessor :name
def initialize(name)
@name = name
end
def say_hello
return "Hello! my name is #{@name}"
end
end
class Counter
attr_accessor :count
def initialize()
@count = 0
end
def increase
@count += 1
end
def say_count
"Count is now: #{@count}"
end
end
def main
daniel = Person.new("Daniel")
eduardo = Person.new("Eduardo")
puts daniel.say_hello() >> "Hello! my name is Daniel"
puts eduardo.say_hello() >> "Hello! my name is Eduardo"
my_counter_instance = Counter.new
new_counter = Counter.new
my_counter_instance.increase()
my_counter_instance.increase()
my_counter_instance.increase()
new_counter.increase()
new_counter.increase()
my_counter_instance.say_count >> "Count is now: 3"
new_counter.say_count >> ???
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment