Game Development Reference
In-Depth Information
6.
Concepts
Provide short definitions of the concepts 'instruction', 'variable', 'method', and
'object'. Which two relations does the concept 'class' have with these con-
cepts?
7.
Declaration, instruction, expression
What's the difference between a declaration, an instruction and an expres-
sion?
8.
Statement versus instruction
Many programming topics use the word 'statement' to indicate an instruction
in a programming language. Why do you think we avoid that word in this
topic?
9.
Changing names
Look at the class
DiscoWorld
that we discussed in Chap.
4
. What do we have to
change if we wanted to change the name of this class into
Hello
? What is not
necessary to change, but is logical to change anyway?
10.
Syntactical categories
Indicate for each of the following program fragments to which syntactical cat-
egory it belongs: (M)ethod call, (D)eclaration, (E)xpression, (I)nstruction, and
(A)ssignment. There may be 0, 1, or 2 correct answers for each.
∗
x
int
x;
int
23;
(y+1)
new
Color(0,0,0)
−
1)
(
int
)x
23
(x+y)(x
new
Color black;
int
(x)
23x0
x+1=y+1;
Color blue;
int
x
x=23;
x=y+1;
GraphicsDevice.Clear(Color.White);
int
x,
double
y;
"x=23;"
spriteBatch.Begin();
Content.RootDirectory = "Content";
int
x, y;
x23
Math.Sqrt(23)
Color.CornflowerBlue
"/"
0x23
"\\"
Color.CornflowerBlue.ToString()
"\"
23%x
(x%23)
game.Run()
∗
23
∗
/
"//"
x
/
""
23=x;
11.
Relation between syntactical categories
Have another look at the five syntactical categories mentioned in the previous
exercise, but now add a sixth one: C(onstant).
(a) Which of the combinations of 2 categories are possible? For example: M+D
is possible if there exists a program fragment that is both a method call and
a declaration.
(b) Which of the six categories are always together with which others?
(c) Which of the six categories always ends with a semicolon? Which some-
times? Which never?