Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS A C++ PROGRAM! You are to write a game called gato . That is Tic-Tac-Toe, for those of you that have not heard

THIS IS A C++ PROGRAM!

You are to write a game called gato. That is Tic-Tac-Toe, for those of you that have not heard the name in Spanish. First you need to draw the board using classes from the graphics library discussed in class. Next, ask the user to click on a empty spot on the board and display alternating Xs and Os on the locations of those mouse clicks. After 9 clicks, presumably when the board has been filled up, the game ends. You must display a Game over message somewhere on the viewing window and proceed to ask the user whether or not another game is to be played. The program should end when the user enters a negative response to this question.

For this assignment you may assume:

  • The user knows how to play the game; that is, once a location of the board is occupied, the user will not try to click on that location again unless a new game has started.

  • The game ends after 9 clicks regardless of whether or not there is an actual winner.

  • The player who draws the Os always gets to start the game (i.e., when the board is empty the first symbol displayed will be an O).

Notice that there could be many individual games of gatoevery time the program is run. You will not know in advance whether the user wants to play 1, or 100 games; your program should adjust accordingly. Also, notice that at every individual game, exactly 5 Os and 4 Xs are to be drawn.

The purpose of this assignment is that you code your program efficiently. You should not repeat the procedure for drawing an O or an X more than necessary. In other words, you should loop the part of your code that performs the drawing rather than simply repeating your code multiple times.

Here is some more information about your assignment:

  • You are not expected to write code that plays the game of Tic-Tac-Toe against the user. Instead, the user will choose all locations for all of the Os and all of the Xs.

  • You are not responsible for tracking poor mouse clicks by the user, such as not clicking within a box or a user clicking all 9 Xs and Os in the same box (remember: you are under the assumption that the user knows how to play the game).

  • You are not responsible for deciding whether or not there is a winner.

    (+1 point) Instead of drawing an O, sketch a guajolotero bus. To get this point, it should be absolutely clear that your sketch indeed represents a guajolotero bus and not just a generic bus.
    (+1 point) End the game at the first occurrence of a 3-in-a-row. In this case, a line through the winning 3 spots must be drawn and you must declare the winner: O or X.
    (+2 points) Write an intelligent Tic-Tac-Toe playing system so that the computer plays against the user.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions