联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2020-11-27 11:37

SEHH2042 2020-2021 Semester 1 – Individual Project Page 1 of 7

SEHH2042 Computer Programming

Individual Project – Connect Four Game

(Due: 18:00, 30 Nov 2020 Monday)

Expected Learning Outcomes

? 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 Connect Four Game that runs in the command line

environment. Player plays against another player by inputting commands to drop checker discs

into a vertically suspended grid. You may find more information about the game via this link:

https://en.wikipedia.org/wiki/Connect_Four

This is an individual project. You need to write a Win32 Console Application program called

ConnectFour.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 you]

*** Game Menu ***

[1] Start Game

[2] Settings

[3] Instructions

[4] Credits

[5] Exit

*****************

Option (1 - 5):

SEHH2042 2020-2021 Semester 1 – Individual Project Page 2 of 7

R1 [1] Start Game

When the user inputs 1 in the Game Menu, the game starts with the current game settings

(see R2). Player 1 and player 2 take turns to drop a checker into the game board. The

game’s objective is to connect four of your checkers in a row (either vertically, horizontally,

or diagonally) while preventing your opponent from doing the same. The game ends when

any one has connected four checkers, or the game board is full. When the game board is

full, the game is drawn.

R1.1 Game Board

The game board size is 6-row, 7-column (6 x 7) vertically suspended grid. 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 game board is given below, with the top-left location identified by A1:

R1.2 Checkers

By default, the game use ‘O’ to represent the player 1’s checkers and ‘X’ to represent the

player 2’s checkers. The checker symbols can be modified in the settings menu, see R2.2

for more details.

R1.3 Player’s move

In each round, the game console should indicate it is which player’s turn and display

appropriate instructions that assist player to drop the checker. When a column is full, the

player cannot drop further checker to that column. The game should check whether input

column name (A to G) is already full. If the column is full, the player should enter another

column for the game to proceed. If all columns were full before the player drop the next

checker, the game should be ended before the input.

SEHH2042 2020-2021 Semester 1 – Individual Project Page 3 of 7

R1.4 Quit command ‘Q’

In each round, instead of inputting a column name to drop the next checker, player can

input ‘Q’ to exit the current game. If this happens, the system should prompt for player’s

confirmation. If the player inputs ‘y’ or ‘Y’, the player loses. The game result should be

displayed, 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 accepted, and the system should ask

the player to confirm again.

R1.5 Game Ends

The game continues until either player win the game or the game board is full. If any player

has 4 checkers in a row (horizontally, vertically or diagonally), that player wins

immediately. If the game board is full, the game is drawn. When the game ends, the game

result is displayed. Then it returns to the Game Menu.

For sample games, please refers to Appendix B.

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.3 below).

*** Settings Menu ***

[1] Who starts first

[2] Checker symbols

[3] Return to Game Menu

*********************

Option (1 - 3):

R2.1 [1] Who starts first

When the user inputs 1 in the Settings Menu, the console displays the current setting of

who starts first (default: player 1 first). The program should let the user to choose either

player 1 or player 2 to start first. There should be relevant prompts for the user input of the

new setting. For invalid input, the program should ask for user input again until a valid

choice is made.

When it is done, the system displays the updated status and returns to the Settings Menu.

SEHH2042 2020-2021 Semester 1 – Individual Project Page 4 of 7

R2.2 [2] Checker symbols

When the user inputs 2 in the Settings Menu, the console displays the current setting of

checker symbols (default: ‘O’ for player 1, ‘X’ for player 2). The program should prompt

for the user input of the new symbols. The program should check that the new symbols are

not space (‘ ’) nor border symbols (‘+’, ‘-’, ‘|’). Symbols of the two players cannot be the

same as well. The symbols will reset back to ‘O’ and ‘X’ if the new symbols were invalid.

When it is done, the system displays the updated symbols and returns to the Settings Menu.

R2.3 [3] Return to Game Menu

When the user inputs 3 in the Settings Menu, the system returns to the Game Menu.

R3 [3] Instructions

The system displays the instructions for playing the game. After displaying the instruction,

the system returns to the Game Menu.

R4 [4] Credits

The system displays your personal details (e.g. student name, student ID, class, tutorial

group, etc.). After displaying the information, the system returns 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 accepted, 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.

SEHH2042 2020-2021 Semester 1 – Individual Project Page 5 of 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.

Submission

Submit one source code file (i.e., ConnectFour.cpp) that implements this project via Moodle

(class page) before the due date. Late submission is NOT accepted.

Grading criteria

Aspects Percentage

Program correctness

(Follow ALL requirements stated above)

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.)

10%

User-friendliness

(Clear guidelines to users, messages to users, etc.)

10%

Total 100% (max)

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.

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.

SEHH2042 2020-2021 Semester 1 – Individual Project Page 6 of 7

Appendix A - Tips

To refresh the console screen, you may use the following windows platform commands

appropriately in your program by adding the header file <stdlib.h>:

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:

int choice;

cin >> choice; // assume incorrect input a string

if (cin.fail()){ // check whether last input was failed

cin.clear(); // Reset the input error status to no error

cin.ignore(255, '\n'); // ignore maximum of 255 characters,

// or reached end of line.

}

// now, it can read again

Appendix B - Sample games.

Players moves

([Player number]: [Column])

Result of the moves

Player 1: A, Player 2: B

Player 1: A, Player 2: C

Player 1: A, Player 2: A

Player 1: B, Player 2: D

Player 1: C, Player 2: E

Game Over, player 2 wins

A B C D E F G

+---------------+

1 | |

2 | |

3 | X |

4 | O |

5 | O O O |

6 | O X X X X |

+---------------+

Player 1: A, Player 2: B

Player 1: A, Player 2: C

Player 1: A, Player 2: D

Player 1: A

Game Over, player 1 wins

A B C D E F G

+---------------+

1 | |

2 | |

3 | O |

4 | O |

5 | O |

6 | O X X X |

+---------------+

SEHH2042 2020-2021 Semester 1 – Individual Project Page 7 of 7

Player 1: A, Player 2: B

Player 1: B, Player 2: C

Player 1: D, Player 2: C

Player 1: C, Player 2: D

Player 1: D, Player 2: E

Player 1: D

Game Over, player 1 wins

A B C D E F G

+---------------+

1 | |

2 | |

3 | O |

4 | O O |

5 | O X X |

6 | O X X O X |

+---------------+

Player 1: A, Player 2: D

Player 1: B, Player 2: B

Player 1: C, Player 2: C

Player 1: A, Player 2: B

Player 1: A, Player 2: A

Game Over, player 2 wins

A B C D E F G

+---------------+

1 | |

2 | |

3 | X |

4 | O X |

5 | O X X |

6 | O O O X |

+---------------+

Player 1: A, Player 2: B

Player 1: B, Player 2: C

Player 1: D, Player 2: C

… (Skipped 36 moves)

Game board is full. Game is a draw.

A B C D E F G

+---------------+

1 | X O X O O X X |

2 | O X O X X X O |

3 | O X O X X O X |

4 | X O O O X O O |

5 | O O X X O O X |

6 | O X X O X X O |

+---------------+

*** Ensure the originality of your work. Plagiarism in any form is highly prohibited. ***

- End -


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp