M206 - TMA01 Question 3
(i) (a) The Frog attributes are colour and position.
(b) The values of the attributes for colour and position are Green and 1 respectively.
c) The initialised state refers to the state ( the values of the attributes) of a newly created object. Instances of the same class may be initialised identically.
(ii)(a) The following must be typed into the text interface to change the frog5 position to 4 and colour to red:
- frog5 position: 4
frog5 colour: Red
(b) Graphically the evidence of successful setting of the attributes is shown by frog5 is now on stone 4 and it colour is now red.
(c) It is possible to check for successful setting of the frog5 attributes by inspecting frog5. Select frog5 and INSPECT, successful setting of the attributes should return the following message "An instance of frog5 position4, Red.
a) The keywords are: hover:, by: and sameColorAs: - Keywords also include arguments.
(b) The messages without arguments are brown and right.
(c) Three messages are sent to hoverFrog as a result of evaluating these for lines. The message selector for the first line is right, the second line is hover: by: and sameColourAs: for the last line. However sameColourAs: actually sends the message hoverfrog3 colour whose message selector is colour to hoverfrog3 to find its colour
(d) In the third line:-
- Receiver Hoverfrog3
Keywords hover: and by:
Message hover: Up by: 3
Arguments Up and 3
(e) Since HoverFrog is a subclass of Frog it follows that since Frog has brown as part of its protocol then the HoverFrog protocol must include brown.