a1specs - ASSIGNMENT 1 COMP-322B, Winter 2011 Due: Tuesday,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ASSIGNMENT 1 COMP-322B, Winter 2011 Due: Tuesday, February 8, 2011 (23:55) You MUST do this assignment individually. The assignment must be submitted via myCourses . Part 1, Question 1: 20 points Part 2, Question 1: 30 points 50 points total Part 1: Conditionals and Arrays Question 1: A Game of Tic-Tac-Toe (20 points) In this question, you will implement a console-based game of tic-tac-toe. Rules of the game: Tic-Tac-Toe is played on a 3-by-3 grid with two players. Each player takes a turn to play either an X or an O on the grid. The Frst player to get three in a row either diagonally, horizontally or vertically wins the game. In order to implement this game, we need to consider the following design criteria: 1. How to store the grid 2. How to select a square on the grid 3. How to alternate players’ turns and ensure they enter a valid selection 4. How to detect a winner or game over Hints: You can use a multidimensional array (3-by-3) to store the grid. Each square in the grid may be represented by a number, so that a player can select a square by entering its number. After each turn, your program should check the grid for a winner (if there are three consecutive X ’s or O ’s). The game should end when there is a winner or when nine turns have elapsed, whichever occurs Frst. Loops will come in handy for this question. On the course webpage, you are provided with a Fle Tictactoe.cpp to help you get started. Sample session: > g++ -Wall Tictactoe.cpp -o tictactoe > ./tictactoe 1 | 2 | 3 --------- 4 | 5 | 6 --------- 7 | 8 | 9 Player 1, please enter the square number to place your X: 7 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1 | 2 | 3 --------- 4 | 5 | 6 --------- X | 8 | 9 Player 2, please enter the square number to place your O: 5 1 | 2 | 3 --------- 4 | O | 6 --------- X | 8 | 9 Player 1, please enter the square number to place your X: 3
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

a1specs - ASSIGNMENT 1 COMP-322B, Winter 2011 Due: Tuesday,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online