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

Assignment Help:

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


Related Discussions:- Write a fragment of code that declares a variable

What are source files and bytecode files, Problem : (a) What do you u...

Problem : (a) What do you understand by the term ‘constructor' in Java? Explain with an appropriate example. (b) Describe the differences between an object and a class usi

C program to print fibonacci series, C program to print fibonacci series: ...

C program to print fibonacci series: int fibo(long int); void main() {                 long int a=0,n;                 printf ("how many terms\n");

Input and output in c++, C++ improves on many of C's features and provides ...

C++ improves on many of C's features and provides object-oriented programming capabilities used for software production, quality and reusability. C++ was developed by Bjarne Strons

Flowchart, create a flowchart that display the assume that there are 3 sect...

create a flowchart that display the assume that there are 3 section each student ?

Lua and C++ sprite animation, How would I use variables of a C++ object wit...

How would I use variables of a C++ object within a Lua function, and then call the Lua function from C++ code?

Poker room auto seat program, Poker Room auto seat program Project Descr...

Poker Room auto seat program Project Description: I want a script for an online poker site. It requires to be scanning all the available tables and when the table meets certa

Change to palindrome, a palindrome is a string that reads the same from bho...

a palindrome is a string that reads the same from bhote the ends

Function declarations and function definitions in cpp, FUNCTIONS It refe...

FUNCTIONS It refers to a subprogram that is meant to do a certain task. It is basically used to execute a set of operations and return information to the main or calling functio

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd