MTD215 Application of C++ in Multimedia Tutor-Marked Assignment 01, 2026
MTD215 Tutor-Marked Assignment 01
Question 1
Implement a C++ program in an object-oriented programming style and use comments to explain the syntax and structure of C++.
(a) Declare the Rectangle class as follows:
(i) Two private variables: Length, Width.
(2 marks)
(ii) Constructor with input of Length and Width.
(2 marks)
(iii) One function to get perimeter.
(2 marks)
(iv) Another function to get aspect-ratio (ratio of Length to Width).
(2 marks)
(v) Another function to get area.
(2 marks)
(b) Write a main() function to demonstrate how the constructors in part (a) are being used.
(i) To get user inputs of Length and Width
(2 marks)(ii) Create objects based on user inputs.
(2 marks)
(iii) Display the perimeter, aspect-ratio, and area of the circle.
(6 marks)
(c) Using SDL or SFML to visualize the rectangle.
(5 marks)
Question 2
Your company is organizing an exhibition match of the game “League of Legends” as team-bonding activity for this month. You are asked to apply C++ to program and implement a player grouping system.
Requirements of the grouping system:
- 10 participants are to be divided into two teams of 5 members each.
- Each participant will be registered with name and performance rating between 1 and 10 points (inclusive).
- To make the exhibition match as exciting as possible, we need to divide the 10 participants into two teams as evenly as possible in terms of skill level. For example, given the gaming performance ratings of the 10 participants as follows: 5, 1, 8, 3, 4, 6, 7, 10, 9, 2, the optimal division would be (1, 3, 5, 8, 10) and (2, 4, 6, 7, 9), resulting in the smallest difference in strength between the two teams, which is 1.
Remember to add comments to explain the syntax and structure of C++ language. Write down codes with comments to implement the following functions:
(a) Receive each participant name and performance rating of each participant.
Hello, Key in name of player#1
David
Please key in player performance ratings (int 1~10)
5
Hello, Key in name of player#2
Tom
Please key in player performance ratings (int 1~10)
1
Hello, Key in name of player#3
Steven
Please key in player performance ratings (int 1~10)
8
Hello, Key in name of player#4
(10 marks)
(b) Your algorithm starts grouping after all 10 participants information received and ultimately displayed the grouping result as shown in the figure below.
Hello, Key in name of player#9
Dave
Please key in player performance ratings (int 1~10)
9
Hello, Key in name of player#10
Lily
Please key in player performance ratings (int 1~10)
2
Grouping……
Group 1:
David – performance rating:5
Tom – performance rating:1
Steven – performance rating:8
Joey – performance rating:3
Simon – performance rating:10
Group 2:
Clark – performance rating:4
Lucy – performance rating:6
Mia – performance rating:7
Dave – performance rating:9
Lily – performance rating:2
The absolute difference value between the two groups: 1
(10 marks)
(c) Calculate and display the absolute difference value between the two groups.
(5 marks)
Question 3
Apply C++ language to program a puzzle game. The puzzle involves arranging a set of twenty-five numbers in an ascending order. The numbers are displayed in a 5×5 grid. These numbers are randomly generated and yet to be sorted. The player is required to sort these numbers by swapping two adjacent numbers each time and ultimately sort the set of numbers in an ascending order. A number can be swapped with another number on its right, left, top or bottom. Take note that a number cannot be swapped with a number that is diagonally adjacent to it.
Figure Q3(i) shows a sample initial screen of the game with the 25 randomly generated numbers arranged in a 5×5 grid.
6073 4651 2378 7193 4839
2625 4374 5132 9387 3626
8645 6040 2053 3616 1338
908 8154 7537 4982 283
3982 4627 8999 2580 4052
Enter the two adjacent location to swap
Location 1 -> column:
Figure Q3(i)
For example, if the number 7537 is to be moved, then it can be swapped with either the number 2053 (top), 8999 (bottom), 8154 (left), or 4982 (right). Any illegal swapping will result in an error message being displayed as shown by Figure Q3(ii). Figure Q3(iii) shows the result of player swapping the numbers 7537 and 2053 in a partially sorted manner.
6073 4651 2378 7193 4839
2625 4374 5132 9387 3626
8645 6040 2053 3616 1338
908 8154 7537 4982 283
3982 4627 8999 2580 4052
Enter the two adjacent location to swap
Location 1 -> column:3
Location 1 -> row:3
Location 2 -> column:3
Location 2 -> row:5
This swap is illegal. Please try again
Enter the two adjacent location to swap
Location 1 -> column:
Figure Q3(ii)
6073 4651 2378 7193 4839
2625 4374 5132 9387 3626
8645 6040 7537 3616 1338
908 8154 2053 4982 283
3982 4627 8999 2580 4052
Enter the two adjacent location to swap
Location 1 -> column:
Location 1 -> row:
Location 2 -> column:
Location 2 -> row:
Figure Q3(iii)
Figure Q3(iv) shows the result if the player has successfully sorted the numbers.
283 908 1338 2053 2378
2580 2625 3616 3626 3982
4052 4374 4627 4651 4839
4982 5132 6040 6073 7193
7537 8154 8645 9387 8999
Enter the two adjacent location to swap
Location 1 -> column:4
Location 1 -> row:5
Location 2 -> column:5
Location 2 -> row:5
283 908 1338 2053 2378
2580 2625 3616 3626 3982
4052 4374 4627 4651 4839
4982 5132 6040 6073 7193
7537 8154 8645 9387 8999
Congratulations! You have sorted the number.
Figure Q3(iv)
You are required to implement the puzzle game with the following specifications:
(a) The program should randomly generate 25 numbers. Different set of numbers should be displayed each time the program is started. The program displays the 25 numbers in a 5×5 grid. Each number should be enclosed in an ASCII box, as shown in Figure Q3(i).
(5 marks)
(b) The program should prompt the player to swap two adjacent numbers as shown in Figure Q3(ii). It should check for illegal moves if the two numbers are not adjacent to each other either horizontally or vertically. It should display an error message if the move is not allowed as shown in Figure Q3(ii).
(5 marks)
(c) If the move is legal, the program should perform the swap and display it on the screen. If the numbers are still not sorted, the program should prompt for the next move, as shown in Figure Q3(iii).
(5 marks)
(d) If the numbers are sorted, the program should display the result and a message informing the user that he has successfully completed the puzzle, as shown in Figure Q3(iv).
(5 marks)
(e) Instead of putting all your codes in the main() function, you should decompose your program into meaningful functions. For example, you should have a function for each of the following tasks:
- Displaying the puzzle.
- Getting input from the user.
- Check if user has selected two locations that are adjacent.
- Check if the numbers are sorted.
(5 marks)
Question 4
(a) Apply C++ and SDL to implement an animation of running stickman with a click button to start/stop in SDL window:
(i) Create a window with resolution of 800*600.
(ii) Use the sprite sheet provided below to display the animation of a running stickman.
| 1 | 2 | 3 | 4 |
| 5 | 6 | 7 | 8 |
(iii) Add a click button at the top-left corner to toggle on/off the animation created in Q4a(ii).
[窗口截图,包含标题栏 “TMA2024-Q4” 和一个位于左上角的红色圆形按钮,以及一个正在奔跑的黑色火柴人图形。]
Figure Q4(ii): Output of SDL program.
(19 marks)
(b) Based on what you have learnt in course and explored online, appraise and discuss SDL for graphic surfaces and multimedia applications by comparing with other APIs or libraries (Choose TWO (2) for comparison). List out both advantages and disadvantages of SDL.
| API/Libraries | Pros | Cons |
|---|---|---|
| SDL | … | |
| … |
(6 marks)
—- End of Tutor-Marked Assignment 01 —-
Hire a Professional Essay & Assignment Writer for completing your Academic Assessments
Native Singapore Writers Team
- 100% Plagiarism-Free Essay
- Highest Satisfaction Rate
- Free Revision
- On-Time Delivery
The post MTD215 Application of C++ in Multimedia Tutor-Marked Assignment 01, 2026 appeared first on Singapore Assignment Help.