Skip to content

Instantly share code, notes, and snippets.

@zben
Created May 18, 2012 22:29
Show Gist options
  • Save zben/2727906 to your computer and use it in GitHub Desktop.
Save zben/2727906 to your computer and use it in GitHub Desktop.
class CompositeTask < Task
def initialize(name)
super(name)
@sub_tasks = []
end
def add_sub_task(task) @sub_tasks << task task.parent = self
end
def remove_sub_task(task) @sub_tasks.delete(task) task.parent = nil
end
def get_time_required
time=0.0
@sub_tasks.each {|task| time += task.get_time_required}
time
end end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment