Skip to content

Instantly share code, notes, and snippets.

/TaskList.rb Secret

Created February 12, 2016 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/99c72e667ff3bb234a84 to your computer and use it in GitHub Desktop.
Save anonymous/99c72e667ff3bb234a84 to your computer and use it in GitHub Desktop.
class List
attr_reader :all_tasks
def initialize()
@all_tasks = []
end
def add_task(task)
@all_tasks << task.description
end
def show
@all_tasks.each { |task| puts task }
end
end
class Task
attr_reader :description
def initialize(description)
@description = description
end
end
my_list = List.new
task_1 = Task.new("Go shopping")
task_2 = Task.new("Do homework")
task_3 = Task.new("Get a job")
my_list.add_task(task_1)
my_list.add_task(task_2)
my_list.add_task(task_3)
my_list.show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment