OU Courese Banner ADBH Web - M206 TMA02 Question 1
ADBH Web Friday 03 September 2010

M206 - TMA02 Question 1

  • (i) An example of a keyword message selector from the protocol of numbers is plus: and one example of a binary message selector is +.
  • (ii) A message that could be used to check if a string is a palindrome is: aString reverse
  • (iii)
  • (a) Order of evaluation a, b, c then d.

Expression evaluation

  • (b) aNumber references the number object 3 after the evaluation of the expression series.

 

  • (iv)
    • (a) The purpose of the textual representation of a message answer is to communicate information about the message answer object to the user. The exact textual representation depends on what the programmer has designed into the object in question.
    • (b)

message expression

class of answer

textual representation of answer

myAccount holder

ByteString

'John Smith'

myAccount balance

SmallInteger

100

(c) Write down an expression which when evaluated will produce a single line of text in the Display pane showing both the holder and the balance of the account referenced by myAccount;

(myAccount holder concatenate:(myAccount balance printString))

step

receiver

message

message answer

1

hisAccount

balance: 100

an Account

2

hisAccount

credit: 20

an Account

3

hisAccount

balance

120

4

herAccount

balance: 120

an Account

5

herAccount

holder: 'Josephine Bloggs'

an Account

  • vi) What are the final states of the objects referenced by slimey, croaker and hopper?
  • This was diagram and has not been included - didn't scan well -sorry.
  •  
  • The final states are..

Object

colour

position

slimey

Green

5

croaker

Brown

5

hopper

Green

5

Question 2

Top of Page

 

 

 

Page built in 0.0005 seconds