Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added the total_number_basic_task method to cound the number of simpl…

…e tasks
  • Loading branch information...
commit c4dcbfb8dbb78aa3649d7949aea7c02159e94bf7 1 parent 9c1a79c
@adomokos authored
View
6 Composite/composite_task.rb
@@ -25,5 +25,11 @@ def get_time_required
@sub_tasks.each { |task| time += task.get_time_required }
time
end
+
+ def total_number_basic_tasks
+ total = 0
+ @sub_tasks.each { |task| total += task.total_number_basic_tasks }
+ total
+ end
end
View
3  Composite/composite_task_spec.rb
@@ -19,6 +19,7 @@ def get_time_required
it "should be able to receive a Task and add it to its task list" do
task = Task.new('simple task')
task.get_time_required.should == 0
+ task.total_number_basic_tasks.should == 1
add_stubbed_task_to_composite_task(task)
@composite_task.get_time_required.should == 0.0
@@ -27,9 +28,11 @@ def get_time_required
it "should be able to receive two StubTasks and add them to its task list" do
add_stubbed_task_to_composite_task(StubTask.new)
@composite_task.get_time_required.should == 3.0
+ @composite_task.total_number_basic_tasks.should == 1
add_stubbed_task_to_composite_task(StubTask.new)
@composite_task.get_time_required.should == 6.0
+ @composite_task.total_number_basic_tasks.should == 2
end
def add_stubbed_task_to_composite_task(task)
View
4 Composite/task.rb
@@ -9,5 +9,9 @@ def initialize(name)
def get_time_required
0.0
end
+
+ def total_number_basic_tasks
+ 1
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.