0% found this document useful (0 votes)
7 views14 pages

22IIITCW011

This document outlines the examination instructions for the Higher Diploma in Game Software Development, including details about the structure and marking of the exam. It consists of two sections: Section A with four questions worth 40 marks and Section B with two questions worth 60 marks, focusing on mobile applications and game technology. Students are required to answer all questions and can use either Java or Kotlin for coding responses.

Uploaded by

kittychan810c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views14 pages

22IIITCW011

This document outlines the examination instructions for the Higher Diploma in Game Software Development, including details about the structure and marking of the exam. It consists of two sections: Section A with four questions worth 40 marks and Section B with two questions worth 60 marks, focusing on mobile applications and game technology. Students are required to answer all questions and can use either Java or Kotlin for coding responses.

Uploaded by

kittychan810c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

© Vocational Training Council

IVE Information Technology

Information & Communications


Technology

Programme Board

Instructions:
(a) This paper has a total of THIRDTEEN pages
HIGHER DIPLOMA IN
including the covering page.
GAME SOFTWARE DEVELOPMENT
(b) This paper contains TWO Sections. (IT114107)

(c) Section A is WORTH 40 marks and Section B


MODULE TITLE:
is worth 60 marks.
(d) Section A contains FOUR questions. Answer MOBILE APPLICATIONS
ALL questions in Section A. AND
(e) Section B contains TWO questions. Answer GAMES TECHNOLOGY
ALL questions in Section B. Each question is MODULE CODE: ITP4721
worth 30 marks.
Note: The result of this assessment will not be
counted if you do not meet the minimum
attendance requirement (if any) governed
by the general academic regulations of your
programme/course unless approval of the
campus principal has been granted.

SEMESTER 2
MAIN EXAMINATION

11 MAY, 2023
1:30 PM TO 3:30 PM (2 hours)
© Vocational Training Council
© Vocational Training Council

Information Technology Discipline Page 1 of 12


Course/Programme/Year: IT114107/2

This paper contains TWO sections.

Section A (40 marks)


This section contains FOUR questions.
Answer ALL questions.
All coding answers can be written in either Java OR Kotlin.

A1 Name ONE of the permissions required for the following features in an


Android Studio Project. Answer “Not required” if the feature is not
necessary to gain any permission.
(i) Allows an app to access precise location. [2 marks]
(ii) Access the network resources. [2 marks]
(iii) Popup a Toast Message [2 marks]
(iv) Access the camera at the front of the mobile device. [2 marks]
(v) Access contact information. [2 marks]

A2 Implement with the following Java and Kotlin code skeleton to create and
display an AlertDialog box with the title “Examination Reminder” with the
content “The examination is going to start tomorrow” with an “OK” button.
You may answer in either Java or Kotlin.
// Java code skeleton begin
private void createReminderDialogBox() {
AlertDialog.Builder adRM = new _(i)__ (this);
adRM. _(ii)__ (R.drawable.android);
adRM. _(iii)__ (false);
adRM. _(iv)__ ("Examination Reminder");
adRM. _(v)__ ("The examination is going to start tomorrow.");
adRM. _(vi)__ ("OK", new DialogInterface. _(vii)__ () {
@Override
public void onClick (DialogInterface dialog, int which) {
AlertDialogDemoActivity.this. _(viii)__;
});
});
adRM. _(xi)__;
adRM. _(x)__;
}
// Java code skeleton end [10 marks]

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 2 of 12


Course/Programme/Year: IT114107/2

// Kotlin code skeleton begin


private fun createReminderDialogBox() {
val adRM: AlertDialog.Builder = _(i)__ (this)
adRM. _(ii)__ (R.drawable.android)
adRM. _(iii)__(false)
adRM. _(iv)__ ("Examination Reminder")
adRM. _(v)__ ("The examination is going to start tomorrow")
adRM. _(vi)__ ("OK")
{ _(vii)__ -> this. _(viii)__ }
adRM. _(ix)__
adRM. _(x)__
}
// Kotlin code skeleton end
Noted: 1 mark will be deducted for each incorrect syntax or naming.

A3 Implement with the following Java and Kotlin code skeleton based on the logic
below:
(I) If the value x is 70+, show a Toast message with A.
(II) If the value x is 60-69, show a Toast message with B.
(III) If the value x is 50-59, show a Toast message with C.
(IV) If the value x is 40-49, show a Toast message with D.
(V) In any case for the value x lower than 40, show a Toast message with
F.
Value is declared in Integer. You may answer in either Java or Kotlin.
// Java code skeleton begin
private void exam(int x) {
//_(code block to be completed)__
}
// Java code skeleton end
// Kotlin code skeleton begin
private fun exam(x: Int) {
//_(code block to be completed)__
}
// Kotlin code skeleton end

Noted: 1 mark will be deducted for each incorrect syntax or naming.


[10 marks]

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 3 of 12


Course/Programme/Year: IT114107/2

A4 Implement with the following Java and Kotlin code skeleton to:
(I) A SharedPreferences named et store the shared preferences in the app.
(II) Retrieve the SharedStringPreferences named time and store in a
String variable named t while the app restores to the main display. The
default value is “” if there is no record.
(III) Store the value from the variable t to the ShareStringPreferences
named time while the app goes off-screen.

You may answer in either Java or Kotlin.


You are NOT necessary to declare the variable name t as it has already
been declared somewhere else in the code.

// Java code skeleton begin


@Override
protected void __(i)__ { // Restore value from SharedPreferences
super. __(i)__;
SharedPerferences sp = __(ii)__ ("et", __(iii)__);
t=sp. __(iv)__ ("time", "");
}
@Override
protected void __(v)__ { // Save value to SharedPreferences
super. __(v)__;
SharedPerferences sp = __(ii)__ ("et", __(iii)__);
SharedPerferences.__(vi)__ me = __(vii)__;
me. __(viii)__ ("time", t);
me. __(ix)__;
} // Java code skeleton end
// Kotlin code skeleton begin
override protected fun _(i)_ { //Restore value from SharedPreferences
super. __(i)__
val sp = __(ii)__ ("et", __(iii)__)
t=sp. __(iv)__ ("time", "")
}
override protected fun __(v)__ {// Save value to SharedPreferences
super. __(v)__
val sp = __(ii)__ ("et", __(iii)__)
val me = __(vi)__ . __(vii)__
me. __(viii)__ ("time", t)
me. __(ix)__
}// Kotlin code skeleton end
Noted: 1 mark will be deducted for each incorrect syntax or naming. [10 marks]

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 4 of 12


Course/Programme/Year: IT114107/2

Section B (60 marks)


This section contains TWO questions.
Answer ALL questions.
All coding answers can be written in either Java OR Kotlin.

B1 (a) Suppose the following Sprite class contains one bitmap for one object (without using
Sprite Sheet) and the origin of sprite are set at the centre position.
/**
* Sprite Class in Java
**/
public class Sprite {
private int x, y, spriteWidth, spriteHeight, vSpeed, hSpeed;
private Bitmap bitmap;
private Paint paint;
private boolean isTouched;

public Sprite(Bitmap bitmap, int x, int y) {


// Implementation not shown
}
public boolean isTouched() { return touched; }
public void setHSpeed(int hSpeed) { this.hSpeed = hSpeed; }
public void setVSpeed(int vSpeed) { this.vSpeed = vSpeed; }
public void setTouched(boolean touched) { this.touched = touched; }
public void handleActionDown(int eventX, int eventY) {
// TO BE COMPLETED in B1(a)(i)
setTouched(true);
else
setTouched(false);
else
setTouched(false);
}
}
public void draw(Canvas canvas) {
// TO BE COMPLETED in B1(a)(ii)
return true;
}
public void update() {
x += hSpeed;
y += vSpeed;
}
}
(B1 CONTINUES IN NEXT PAGE)

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 5 of 12


Course/Programme/Year: IT114107/2

(B1 CONTINUED FROM PREVIOUS PAGE)

/**
* Sprite Class in Kotlin
**/
open class Sprite {
var x: Int
var y: Int
var spriteWidth: Int
var spriteHeight: Int
var vSpeed: Int
var hSpeed: Int
private var bitmap: Bitmap
var paint: Paint
var isTouched = false

constructor(bitmap: Bitmap, x: Int, y:Int) {


// Implementation not shown
}

fun handleActionDown(eventX: Int, eventY: Int) {


// TO BE COMPLETED in B1(a)(i)
isTouched = true
else
isTouched = false
else
isTouched = false
}
fun void draw(canvas: Canvas) {
// TO BE COMPLETED in B1(a)(ii)
return true
}
fun update() {
x += hSpeed
y += vSpeed
}
}
(i) Implement suitable if logic (TWO if statement required) in the
handleActionDown() method to update the touch status -
isTouched of sprite [10 marks]
(ii) Implement suitable codes logic in the draw() method to draw
bitmap object of the sprite on the canvas object. [5 marks]
(B1 CONTINUES IN NEXT PAGE)

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 6 of 12


Course/Programme/Year: IT114107/2

(B1 CONTINUED FROM PREVIOUS PAGE)

(b) Assume a separated class called MainThread, which


contains a Game Loop, is implemented method
initGame(). This method is called before entering the
Game Loop and the methods update() and render()
which are called during each Game Loop accordingly.
Given the screen capture of the game on the left and the For every game
following partial definition of MainGamePanel Class: loop, move left
5 pixels and
move up 5 pixel
[Note: the code below has relation to the code in vertically
B1(a)]

/**
* MainGamePanel Class in Java
**/
public class MainGamePanel extends SurfaceView implements
SurfaceHolder.Callback {
private MainThread thread;
Sprite sprite;
public MainGamePanel(Context context) {
super(context);
getHolder().addCallback(this);
thread = new MainThread(getHolder(), this);
setFocusable(true);
}
public void surfaceChanged( // …Implementation not shown
public void surfaceCreated( // …Implementation not shown
public void surfaceDestroyed( // …Implementation not shown

protected void initGame() {


// TO BE COMPLETED in B1(b)(i)
}

@Override
public boolean onTouchEvent(MotionEvent event) {
// TO BE COMPLETED in B1(b)(ii)
return true;
}

protected void render(Canvas canvas) { // …Implementation not shown }

protected void update() {// …Implementation not shown}


}
(B1 CONTINUES IN NEXT PAGE)

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 7 of 12


Course/Programme/Year: IT114107/2

(B1 CONTINUED FROM PREVIOUS PAGE)

/**
* MainGamePanel Class in Kotlin
**/
class MainGamePanel : SurfaceView, SurfaceHolder.Callback {
private var thread: MainThread
private lateinit var sprite: Sprite

constructor (context: Context) : super(context){


holder.addCallback(this)
thread = MainThread(holder, this)
isFocusable = true
}
override fun surfaceChanged( // …Implementation not shown
override fun surfaceCreated( // …Implementation not shown
override fun surfaceDestroyed( // …Implementation not shown

internal fun initGame() {


// To be completed in B1(b)(i)
}

override fun onTouchEvent(event: MotionEvent) : Boolean {


// To be completed in B1(b)(ii)
return true
}

internal fun render(canvas: Canvas) { // …Implementation not shown }

internal fun update() {// …Implementation not shown}


}

(i) Implement the code block in initGame() method to set the


horizontal and vertical speed so that the sprite moves left 5 pixels
and up 5 pixels per game loop. The spirit image is stored as
mainChar in drawable resource folder and it should be started
moving from (400,400). [9 marks]
(ii) Implement the code block in onTouchEvent() method to handle
the touch event with the following logics:
• If the spirit is being touched, it will call handleActionDown()
in Sprite class with the current location. [2 marks]
• If the spirit is moved by the user’s finger, the location of the
spirit is updated. [2 marks]
• If the user releases the spirit, the isTouched status is updated. [2 marks]

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 8 of 12


Course/Programme/Year: IT114107/2

B2 A simple Android Application called B2API contains a class, namely, MainActivity.


The sample output and the component names are shown as follow:

@+id/btnRandom

@+id/tvCity
@+id/tvName

@+id/tvLocation

@+id/imgPhoto

(a) In the MainActivity, there are 5 variables defined to map to the


components and named as follow:
Class Name Description
TextView tvName Map to @+id/tvName
TextView tvCity Map to @+id/tvCity
TextView tvLocation Map to @+id/tvLocation
ImageView imgStadium Map to @+id/imgPhoto
Button btnRandom Map to @+id/btnRandom with click event
Implement the onCreate() method in Java or Kotlin as shown below to
map the components to the variables.

// In Java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// TO BE COMPLETED in B2(a)
}
// In Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// TO BE COMPLETED in B2(a)
}
[3 marks]
(B2 CONTINUES IN NEXT PAGE)

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 9 of 12


Course/Programme/Year: IT114107/2

(B2 CONTINUED FROM PREVIOUS PAGE)

(b) While the user clicks on the “Random” button, the program calls the method
requestWebAPI() with a random number. The requestWebAPI() method request
the API and wait for the response data in JSON format. The sample JSON content of
the response is shown as follow:
{
"stadium": {
"id": 4,
"n": "Kaliningrad Stadium",
"c": "Kaliningrad",
"location: {
"lat": 54.698157,
"lng": 20.533859
}
"img": "https://upload.wiki.org/wikipedia/com/a/a4/_2018-04-07.jpg"
}
}

Implement the following Java or Kotlin code block to display the text
data only to the designated TextViews defined at the beginning of B2.
// In Java
String responseString = responseTextFromAPI;
// TO BE COMPLETED in B2(b)

// In Kotlin
val responseString = responseTextFromAPI
// TO BE COMPLETED in B2(b)
[12 marks]

(B2 CONTINUES IN NEXT PAGE)

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 10 of 12


Course/Programme/Year: IT114107/2

(B2 CONTINUED FROM PREVIOUS PAGE)

(c) In the JSON response, there is a URI which points to the Internet resource (image). A
thread is required to retrieve the data and display at the ImageView. Implement the
following Java or Kotlin code block with the Executor and display the image to the
ImageView (imgStadium).

Hints:
1. You need to apply the decodeStream() in BitmapFactory class to decode the
image from the Internet.
2. You need to apply setImageBitmap() in ImageView to read the decoded
Bitmap image.
// In Java
ExercutorService imgThreadPool = new Executors.newFixedThreadPool(1);
imgThreadPool.execute(new Runnable() {
@Override
public void run(){
try {
URL url = new URL(_(i)_);
url. _(ii)_;
Bitmap image = BitmapFactory. _(iii)_;
runOnUiThread(() -> imgStadium. _(iv)_ (image));
} catch (_(v)_ e) {
e.printStackTrace();
}
}
}

// In Kotlin
val imgThreadPool: ExecutorService = Executors.newFixedThreadPool(1)
val json = JSONObject(r)
imgThreadPool.execute {
try {
val url = URL(_(i)_). _(ii)_
val image = BitmapFactory. _(iii)_
runOnUiThread {
imgStadium. _(iv)_ (image)
}
} catch (e: _(v)_) {
e.printStackTrace()
}
[15 marks]

***** END OF PAPER *****

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 11 of 12


Course/Programme/Year: IT114107/2

Appendix A Java Commonly Used Name


TextView onTouchEvent
.setText() MotionEvent.ACTION_DOWN
Button MotionEvent.ACTION_UP
.setOnClickListener() MotionEvent.ACTION_POINTER_DOWN
ImageView MotionEvent.ACTION_POINTER_UP
.setImage() MotionEvent.ACTION_MOVE
.setImageBitmap()
EditText Canvas
getText() Bitmap
setText() drawBitmap()
getResources
Options Menu getWidth
onCreateOptionsMenu() getHeight
onOptionsItemSelected()
BitmapFactory
Context Menu .decodeResource()
registerForContextMenu () .decodeStream()
onCreateContextMenu ()
onContextItemSelected () JSONObject
JSONArray
getJSONObject()
getString()
getJSONArray()
getJSONString()

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)
© Vocational Training Council

Information Technology Discipline Page 12 of 12


Course/Programme/Year: IT114107/2

Appendix B Kotlin Commonly Used Name


TextView onTouchEvent
.text MotionEvent.ACTION_DOWN
Button MotionEvent.ACTION_UP
.setOnClickListener() MotionEvent.ACTION_POINTER_DOWN
ImageView MotionEvent.ACTION_POINTER_UP
.image MotionEvent.ACTION_MOVE
.setImageBitmap()
EditText Canvas
getText() Bitmap
setText() drawBitmap()
resources
Options Menu width
onCreateOptionsMenu() height
onOptionsItemSelected()
BitmapFactory
Context Menu .decodeResource()
registerForContextMenu () .decodeStream()
onCreateContextMenu ()
onContextItemSelected () JSONObject
JSONArray
getJSONObject()
getString()
getJSONArray()
getJSONString()

Mobile Applications and Games Main Examination Semester 2 (2022/2023)


Technology (ITP4721)

You might also like