Created
March 27, 2015 16:49
-
-
Save joey-g/7fdf80e7cb5bf49d597c to your computer and use it in GitHub Desktop.
Automation Training Week 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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