Tuesday, February 8, 2011

Smalltalk tiny exercise for TDD newbies

Done in course:

Create the category Exercise in the Browser. All classes you create will be placed in this category.

Implement the class Operation (using Test-Driven Development) which should work like this:
  1. a := Operation new.
    a result.
    Should return 0.
  2. b := Operation new.
    b add: 2.
    b add: 3.
    b result.
    Should return 5.
  3. Operation new
      add: 2;
      add: 4;
      divideBy: 2;
    Should return 3.

Add the message Operation>>#multiplyBy by yourself.

No comments:

Post a Comment