MTD215 Tutor-Marked Assignment 01
This assignment is worth 15% of the final mark for MTD215 Application of C++ in Multimedia.
The cut-off date for this assignment is 5 October 2026, 23:55hrs.
Question 1
Design and explain a Rectangle class that encapsulates the properties of a rectangle and supports basic geometric calculations. The program should follow object-oriented programming principles and include clear comments explaining each part.
(a) Define the Rectangle class:
(i) TWO (2) private member variables: length and height
(ii) Constructor that takes length and height as input and initialises the object.
(iii) Member functions to compute area with display of length and height:
- Area of the original rectangle
- Area after increasing twice the height
- Area after reducing length by half
(10 marks)
(b) Write and explain a main() function that
(iv) Prompt the user to input length and height values.
(v) Create a Rectangle object with the inputs.
(vi) Display the THREE (3) calculated area, length and height.
(5 marks)
(c) Extend the program using SDL to visually draw the THREE (3) rectangles based on the length and height entered by the user.
(5 marks)
Question 2
Design and develop a basic calculator with similar keys and display as the handphone calculator app.
(a) Display the input keys and calculation output on screen.
(4 marks)
(b) Perform calculation processes with below examples and include others.
(i) Basic operators such as add, subtract, multiply, divide
(ii) Complex operators such of mod, sqrt, square etc
(10 marks)
(c) Allow input of formula list for calculation, backspace to clear input and select equal sign to process the calculation with display of calculated results.
(6 marks)
Question 3
Design and implement a trivial quiz game where the player is given a list of random questions to answer within a fixed time limit and the scores are displayed at the end of game.
(a) Create a list of trivial questions with FOUR (4) possible answers for random generation of TWENTY (20) questions in each game.
(5 marks)
(b) Prompt player to enter name, generate a welcome message and select difficulty level of the questions asked.
(5 marks)
(c) Allow player to choose the correct answer, move to the next question after answer is selected and continue process until the end of game.
(5 marks)
(d) Maintain the player score each time a correct answer is selected and display total on screen.
(5 marks)
(e) When the game is over, congratulate player on the score achieved with name and prompt player whether want to replay or exit game.
(5 marks)
(f) Modularise the code by writing separate functions like below examples.
- Start game
- Ask question
- Select answer
- Manage score
- End game
(5 marks)
Question 4
(a) Use SDL to design and apply a simple animation where a coloured circle moves left and right, up and down following the keyboard buttons pressed, without moving out of the window edge.
- Create a window of size 800×600.
- Animate a circle of radius 20 pixels.
- Use keyboard buttons to control the animation movement.
- Apply formula to control maximum movement within window edge.
(14 marks)
(b) Add on enhancements for the circle to bounce back automatically with a random angle upon reaching the window edge. Briefly explain and discuss the program logic and formula used.
(12 marks)
(c) Include manual or automated movement selection button and an exit button to end the animation.
(4 marks)
—- End of Tutor-Marked Assignment —-
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