13.07.2015 Views

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

| m1 m2 |m1 := Moneyamount: 5currency: #USD.m2 := Moneyamount: 7currency: #GBP.m1 + m2 + m1 7 GBP + 5 USD + 5 USDThe final combination is adding a MoneySum to a MoneySum. We do this by concatenating themonies of both of them:MoneySum>>addMoneySum: aMoneySum^MoneySum monies: monies , aMoneySum moniesWe can test this:| m1 m2 |m1 := Moneyamount: 5currency: #USD.m2 := Moneyamount: 7currency: #GBP.(m1 + m2) + (m1 + m2) 7 GBP + 5 USD + 7 GBP + 5 USD<strong>Coding</strong> <strong>Patterns</strong> page 146 of 147 9/30/2006

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!