Skip to content

Instantly share code, notes, and snippets.

@joey-g
Created March 27, 2015 16:49
Show Gist options
  • Save joey-g/7fdf80e7cb5bf49d597c to your computer and use it in GitHub Desktop.
Save joey-g/7fdf80e7cb5bf49d597c to your computer and use it in GitHub Desktop.
Automation Training Week 8
class TodoItem
attr_reader :name
attr_accessor :status
def initialize(arg1)
@name = arg1
@status = false
end
end
class TodoList
attr_reader :todo_items
def initialize
@todo_items = []
end
def add_item(item)
@todo_items.push(item)
end
def get_complete_count
count = 0
@todo_items.each do |el|
if el.status == true
count += 1
end
end
return count
end
end
my_item = TodoItem.new('Buy Milk')
my_item.status = true
my_item2 = TodoItem.new('Buy Cereal')
my_list = TodoList.new
my_list.add_item(my_item)
my_list.add_item(my_item2)
puts 'Completed Items: ' + my_list.get_complete_count.to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment