a write a fragment of code that declares a


(a) Write a fragment of code that declares a variable colSp of type ColourSpot, and then moves it to the point (3, -4), and sets its colour to Green.

(b) A function QU8 is specified below.

function QU8(s in ColourSpot) return in ColourSpot pre true.

post the state of the returned spot is as follows. (X + 2, Y, Red) if s has state (X, Y, Black). (X,Y + 1, Green) if s has state (X,Y, Red).
(X + 2,Y, Blue) if s h a s state {X,Y, Green). (X,Y + 1, Black) if s has s t a t e (X,Y, Blue).

(i) Suppose that, the variable colSp is of type ColourSpot and is in the s t a t e (3,-4, Green).
Use the specification of QU8 to determine the s t a t e of colSp after execution of the following code fragment.


colSp <- QU8(colSp)

colSp <- QU8(colSp)

colSp <- QU8(colSp)

colSp <- QU8(colSp)

(ii) Write code to implement the function QU8

(iii) Use the WorkPad to test the implementation of QU8 which you gave in part (ii). Four test cases are sufficient for your TMA answer. One of them should test an input spot in t h e state (3, 4, Green). Save the WorkPad file which you are using to test your implementation and include the contents of this file as pari of your Solution Document. Also, copy the contents of the Output Window that, you obtain when testing, and include this with your Solution Document.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: a write a fragment of code that declares a
Reference No:- TGS0208975

Expected delivery within 24 Hours