CCN2042 Computer Programming
• familiarise themselves with at least one high level language programming environment.
• develop a structured and documented computer program.
• understand the fundamentals of object-oriented programming and apply it in computer
program development.
• apply the computer programming techniques to solve practical problems.
Introduction
In this assignment, you are going to develop a Drop Block Game that runs in the command line
environment. Player scores by putting blocks of various labels onto a square game board, and by
merging connected blocks with same label.
This is a group assignment. You need to form. a group with 5 to 6 students, and write a Win32
Console Application program called dropBlock.cpp. The requirements are listed below.
System Requirements
R0 When the program starts, the console should display a welcome message, and then the
Game Menu of the program. User can enter the options of the corresponding actions (see
R1 to R5 below).
Welcome Message designed by your group
*** Game Menu ***
[1] Start Game
[2] Settings
[3] Instructions
[4] Credits
[5] Exit
*****************
Option (1 - 5):
CCN2042 17-18 Semester 2 – Group Project 2
R1 [1] Start Game
When the user inputs 1 in the Game Menu, the game starts with an empty game board
and a segment of two connected blocks. In each turn, the player needs to determine where
to drop the segment onto the board to score. After dropping the segment, a new segment
is generated for the next turn. By producing three or more connected blocks of the same
label, the blocks are merged into a single block and extra scores are given.
You are free to design a good way to show the game status information and prompt
messages. But the console should display at least the followings: (1) the total marks
scored by the player, (2) the updated game board, and (3) the next segment of connected
blocks to be dropped.
R1.1 Game board
The player plays on a game board with a default size 6 × 6. The game board is enclosed
by a boundary with characters ‘|’ for vertical boundary, ‘-’ for horizontal boundary, and
‘+’ for the corner. Each location in the board is identified by a letter and a number.
An example of board with default size (6 × 6) is given below, with the top-left location
identified by A0:
0 1 2 3 4 5
+-------------+
A | |
B | |
C | |
D | |
E | |
F | |
+-------------+
R1.2 Blocks
In each turn, the game generates a segment of two connected blocks. You are free to
design whether the blocks are connected vertically or horizontally. Each block associates
with a label randomly generated from X, O, #, and $.
CCN2042 17-18 Semester 2 – Group Project 3
R1.3 Game Play – Dropping blocks
The player may enter “r” or “R” to rotate the segment clockwise by 90 degrees. If the
player inputs multiple times, the segment is rotated accordingly the same number of times
(e.g. “rrr” indicates to rotate 270 degrees clockwise.). Note that at most 3 rotations are
allowed, as rotating the segment more than 3 times is redundant.
The input location should be a column number. It indicates where the segment is dropped
onto the board. If the segment has blocks connected horizontally, then the input indicates
the location of left-block of that segment to drop onto the board.
For each move, the player can rotate the segment and specify the location to drop the
segment with a single command. For example, input “rrr4” stands for rotating 270
degree and dropping at column 4; or input “2” stands for dropping at column 2 without
rotation.
Due to gravity, each block is dropped to fill the empty space underneath. In case of
dropping segment with horizontal connected blocks, the segment may be split during the
process. The scenario below demonstrates an example of dropping the segment (X O)
from column 0:
0 1 2 3 4 5
+-------------+
A | X O |
B | |
C | |
D | $ # |
E | X $ O |
F | X O O $ $ # |
+-------------+
0 1 2 3 4 5
+-------------+
A | |
B | |
C | |
D | X O $ # |
E | X $ O |
F | X O O $ $ # |
+-------------+
0 1 2 3 4 5
+-------------+
A | |
B | |
C | |
D | X $ # |
E | X O $ O |
F | X O O $ $ # |
+-------------+
Drop (X O) at location 0 (X O) reaches the bottom Block O drops further
R1.4 Game Play – Merging blocks
If the player drops the blocks that can successfully connect three or more blocks of the
same label, then these blocks will be merged into one single block of that label. The
blocks are merged towards the bottom-left direction. All remaining blocks above the
merged blocks will be dropped to fill the empty space.
Continue from the above example in R1.3, the blocks are merged as follows:
CCN2042 17-18 Semester 2 – Group Project 4
0 1 2 3 4 5
+-------------+
A | |
B | |
C | |
D | X $ # |
E | X O $ O |
F | X O O $ $ # |
+-------------+
0 1 2 3 4 5
+-------------+
A | |
B | |
C | |
D | $ # |
E | O $ O |
F | X O O $ $ # |
+-------------+
1. There are three connected blocks of label X, merge them towards F0.
0 1 2 3 4 5
+-------------+
A | |
B | |
C | |
D | $ # |
E | O $ O |
F | X O O $ $ # |
+-------------+
0 1 2 3 4 5
+-------------+
A | |
B | |
C | |
D | # |
E | $ O |
F | X O $ $ $ # |
+-------------+
2. There are three connected blocks of label O, merge them towards F1.
The remaining blocks in column 2 are dropped to fill the empty space.
0 1 2 3 4 5
+-------------+
A | |
B | |
C | |
D | # |
E | $ O |
F | X O $ $ $ # |
+-------------+
0 1 2 3 4 5
+-------------+
A | |
B | |
C | |
D | |
E | # |
F | X O $ O # |
+-------------+
3. There are four connected blocks of label $, merge them towards F2.
The remaining blocks in column 3 are dropped to fill the empty space.
R1.5 Game Play – Scoring system
Each drop of a segment scores 20 marks. If there is a merge, the more blocks involved in
a merge would result in higher marks. In addition, if there are multiple merges in one
move, the merge score will be multiplied according to the number of merges. The scoring
system is summarized in the tables below:
CCN2042 17-18 Semester 2 – Group Project 5
Number of blocks in one merge Marks
3 100
4 200
5 400
6 800
Number of merges in one move Multiplier
1 1
2 2
3 4
4 8
… …
Following the example in R1.3 and R1.4, there are scores from (1) dropping the segment,
(2) merging blocks X, (3) merging blocks O, (4) merging blocks $, and (5) 3 merges in 1
move. The total scores for this turn would be 20 + (100 + 100 + 200) * 4 = 1620.
R1.6 Game Play – Command “Quit”
Player can input a special command “Quit” to quit the game at any time during the game.
If this happens, the system should prompts for player’s confirmation. If the player inputs
‘y’ or ‘Y’, the game ends and the system returns to the Game Menu. If the player inputs
‘n’ or ‘N’, the game continues at its current status. Other input is not acceptable and the
system should ask the player to confirm again.
R1.7 Game Play – Game ends
The game finishes when the player fails to put any blocks onto the game board. If the
game finishes, the final score should be displayed and the program returns back to the
Game Menu.
R2 [2] Settings
When the user inputs 2 in the Game Menu, the console displays the Settings Menu. User
can enter the options of the corresponding actions (see R2.1 to R2.2 below).
*** Settings Menu ***
[1] Change Board Size
[2] Return to Game Menu
*********************
Option (1 - 2):
CCN2042 17-18 Semester 2 – Group Project 6
R2.1 [1] Change Board Size
When the user inputs 1 in the Settings Menu, the console displays the current setting of
board size (default: 6 × 6), and prompts for the user input of the new setting. Since the
board is in square shape, user is required to input one integer value only. For example,
user inputs the value 8 to update the board size to 8 × 8.
Note that the acceptable board size is from 6 × 6 to 10 × 10 only. After the setting is
updated, it displays the updated board size and then returns back to the Settings Menu.
R2.2 [2] Return to Game Menu
When the user inputs 2 in the Settings Menu, the system returns back to the Game Menu.
R3 [3] Instructions
The system displays the instructions for playing the Drop Block Game. After displaying
the instruction, the system returns back to the Game Menu.
R4 [4] Credits
The system displays the personal particulars (e.g. student name, student ID, class, tutorial
group, etc.) of the group members. After displaying the information, the system returns
back to the Game Menu.
R5 [5] Exit
When the user inputs this option, the system prompts for user’s confirmation. If the user
inputs ‘y’ or ‘Y’, the program terminates. If the user inputs ‘n’ or ‘N’, the system returns
to the Game Menu. Other input is not acceptable and the system should ask the user to
confirm again.
Other General Requirements
R6 Meaningful guidelines should be printed to assist with user’s input. Whenever an option
is selected, meaningful messages should be displayed.
R7 Suitable checking on user’s input is expected. Appropriate error messages should be
printed whenever unexpected situation happens, e.g., invalid input, input out-of-range, etc.
CCN2042 17-18 Semester 2 – Group Project 7
R8 The use of functions (in addition to main function) and classes are expected in your
program. Appropriate comments should be added in your source code file.
R9 Creativity and Critical Thinking: other features that you find useful or can enhance the
user experience can also be implemented.
Submission
Source File: Each group has to submit one source code file (i.e., dropBlock.cpp) that
implements this group project.
Peer-to-peer Evaluation: Each student has to fill in and submit the peer-to-peer evaluation form.
(i.e., CCN2042_P2P_Evaluation.docx) for your group.
All submission should be done through Moodle by 18:00, 21 April 2018. Late submission is
subject to 20% deduction in your final marks for each day (including public holidays and
Sundays). No late submission is allowed 4 days after the due date.
Grading criteria
Aspects Percentage
Program correctness
(Follow ALL instructions, marks deduction on errors found) 70%
Program design
(Appropriate use of functions, use of class, modularity, etc.) 10%
Program standard
(Use of variable names, indentation, line spacing, clarity, comments, etc.) 5%
Algorithm design
(Use of reasonable algorithms and data structures) 5%
User-friendliness
(Clear user interface, clear guidelines / messages to users, etc.) 5%
Creativity and critical thinking
(Additional useful features) 5%
Total (Group Mark) 100% (max)
CCN2042 17-18 Semester 2 – Group Project 8
Note: the length of your program does not affect the grading of the assignment. However,
appropriate use of loops and functions are expected to avoid too many repeated codes in your
program, which contributes to the program design score of this assignment.
Individual mark is determined by both group mark and percentage of individual contribution,
where the percentage of individual contribution is directly proportion to the average marks given
by group members in the peer-to-peer evaluation form.
Individual mark is calculated by the formula below:
Individual Mark = Group Mark × Percentage of Individual Contribution
Note: You may score 0 mark if you have 0% contribution.
Marks deduction
Marks will be deducted if the program fails to be compiled. The deduction is from 5 to 20 marks,
depending on how serious the syntax error is. Note that if the program contains unacceptably too
many serious syntax errors, your program will score 0 marks.
Syntax errors also lead to failure in the program correctness if the function cannot be tested. So
please make sure that your program can be compiled successfully before your submission.
Tips
To refresh the console screen, you may use the following windows platform. command
appropriately in your program by adding the header file :
system("cls"); // Clear everything on the screen.
system("pause"); // Wait until user pressing any key to continue.
To handle unexpected input error (e.g. input a character to an integer variable), you may use the
following code appropriately in your program:
cin.ignore(); // Discard the content in the input sequence.
cin.clear(); // Reset the input error status to no error.