CS 3304 Homework #10

Date Assigned: December 3, 2003
Date Due: December 10, 2003, in class, before class starts
  1. (20 points) Consider the following Smalltalk implementation of Euclid's gcd algorithm:
    gcd: other
       [self = other]
            ifTrue: [^ self]
        [self < other]
            ifTrue: [^ self gcd: (other - self)]
    	ifFalse: [^ other gcd: (self - other)]
    
    Trace the messages involved in evaluating 4 gcd: 6.

  2. (10 points) In Smalltalk, everything is an object, even a class. Is this a good design choice? What advantages does this provide, over say C++/Java? What disadvantages does this approach have?

  3. (20 points) What is the difference between over-riding a method and overloading a method? Does Smalltalk offer both features?

Return Home