Write a fragment of code that declares a variable, C/C++ Programming

(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.

Posted Date: 3/7/2013 1:52:08 AM | Location : United States

Related Discussions:- Write a fragment of code that declares a variable, Assignment Help, Ask Question on Write a fragment of code that declares a variable, Get Answer, Expert's Help, Write a fragment of code that declares a variable Discussions

Write discussion on Write a fragment of code that declares a variable
Your posts are moderated
Related Questions
By pressing ‘6’ (i.e. key’6’ one time) on the keypad, the mobile shows ‘m’ on display screen in write text message area .

Q: How can Define an Array? An Array is defined in much the alike manner as ordinary variables except that every array name must be accompanied by a size specification (that is

Many modern cryptography algorithms require two numbers that are coprime, or sometimes referred to as relatively prime. Two numbers are coprime if their greatest common divisor is

Write a program that predicts users’ age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an initial gues

how c program starts executing?

give a program to accept and print 2_D Array

C program to demonstrate Pointer to array: void p2a(int *); void main() {                 int x=10, *a,**b;                 int arr[5];                 a=&x;//po

A: In C++ there is a main difference among a template and a macro. Merely a macro is a string which the compiler replaces along with the value that was defined. For example #define

Public, Private and Protected members: Class members can either be declared in public','protected' or in the 'private' sections of the class. But as one of the features of OOP i

Operators The variables, which are declared and explained, are the operands, which are operated upon by the operators. Operators specify what operations are to be performed on