Write program that will allow two users to play tic-tac-toe

Assignment Help Programming Languages
Reference no: EM131344123

Program: Tic Tac Toe

Write a program that will allow two users to play tic-tac-toe. The program should ask for moves alternatively from player X and player O. The display should be board-like:

1 2 3
4 5 6
7 8 9

The players enter their moves by entering a number corresponding to the place to be marked. After each move, the program displays the changed board. After several moves the board may look like this:

X X O
4 5 6
O 8 9

You will write a class called Game. The class will have as a data member

1) an array of size 9, type char, called board

It should also have the following member functions:

A constructor that takes no parameters but initializes the game board to 1 through 9

A function that displays the game board. Remember that after ever 3 elements, it should print a new line so that the board displays as shown above. The board needs to be displayed before every move.

A function called play that will take in at least one parameter of either X or O, depending on which player's turn it is. Additionally, you could add the parameter of the move that player entered (or you could ask for the input within this function). The main purpose of this function is to modify the game board. It must check that only 1 through 9 has been entered, that the space the user has chosen is not yet taken, and then change the game board accordingly. It is up to you to give the player another turn or to pass to the next player if they have chosen an incorrect space.

A function called checkWin, which checks to see if there are any winners. In tic-tac-toe, you win with all of the same marker across, down, or diagonal. You may want this to be a Boolean function.

If you would like to add more data members or functions, you may do so, but the 5 above are required.

Reference no: EM131344123

Questions Cloud

Examine ways that cultural expressions influence daily life : Examine the ways that cultural expressions influence your daily life. You are welcome to use images in this Assignment, however, the written content needs to be at least 750 words
Concept of discount rate-weighted average cost of capital : What is the general intention behind the Truth-in-Lending law? List three requirements under this regulation. Explain the concept of a discount rate and the weighted average cost of capital.  Provide a detailed overview of the top-down, three-step ap..
Create a literature review incorporating each of references : Create a literature review, incorporating each of your references (minimum of five), tying them to each other and to the thesis of your project in a single narrative. You should cite each source in the body of your literature review and in a refer..
Determine the distance x locating the weight a : The self-regulating floodgate ABC, pinned at B, is pressed against the lip of the spillway at C by the action of the 3645-lb weight A. If the gate is to open when the water level reaches a height h = 6 ft, determine the distance x locating the wei..
Write program that will allow two users to play tic-tac-toe : BIS 320- Write a program that will allow two users to play tic-tac-toe. The program should ask for moves alternatively from player X and player O.
Develop a plan to reduce driving under the influence : For your selected age group, develop a plan to reduce driving under the influence. The plan could include (but not be limited to) educational, legislative, and community support; and social advertising. Present at least three action points in your..
Find the smallest wind load q that would cause the structure : Compute the magnitudes of the reactions at A and B if the wind load on the billboard is q = 120 lb/ft.
Theories of lamers and kubler-ross : Imagine that you are a hospice volunteer and are helping late adult, terminally ill patients and their families. Use the theories of Lamers and Kubler-Ross to help you and the families better understand and deal with their circumstances
What are the desirable attributes : What are the desirable attributes of a successful portfolio manager? What was the problem with the early performance measures and how have the modern composite portfolio performance measures overcome this problem

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd