Write a program that plays a tic-tac-toe game.

Assignment Help C/C++ Programming
Reference no: EM13159228

Using functional decomposition, write a program that plays a tic-tac-toe game. Ask the user if they want to go first; the player (user or computer) that goes first is designated X and the other player is O. The board is represented by three one-dimensional arrays (a, b, and c) each with three members (0, 1, 2). The players take turns making moves by designating a letter and a number; e.g., a1. Each player's move must be evaluated to make sure it is valid (within the range and not already occupied). If the user makes a bad move, tell them and ask for another move. If the computer makes an invalid move, keep getting a move until one is valid

In this game, the computer is not intelligent; its moves are random.

A player wins if they occupy three positions in a row; e.g., a1, b1, and c1, or a0, a1, and a2, etc.. Don't forget diagonals.

Before the game starts and after each valid move, show the user the board. Use a combination of spaces, dashes, and vertical lines.

The game ends when a player wins or the maximum number of moves has occurred. If the maximum number of moves takes place and there is no winner, the game is a tie. Tell the user what the result is (winner or tie).

When the game is over, ask the player if they want to play again. If yes, clear the board and start again; if no, say good bye and exit.

Use functions as appropriate.

 

 

Reference no: EM13159228

Questions Cloud

How did this likely affect labours share in national income : Does an increase in the average annual labour income imply that the individual worker's labour income has increased and
How does the hiv virus make new viral proteins : How does the HIV virus make new viral proteins and viral genomes, Which of these processes are carried out by viral vs. human enzymes/structures? How does the virus get out again or be totally eliminated from the body? Remember to focus on the flo..
Family-status of children-role of women : Research what a person would need to know in order to visit your country successfully. In your search, look for topics such as family, status of children, role of women, role of the aged, customs,
Fair-value of identifiable net assets : In a business combination accounted for as an acquisition, how should the excess of fair value of identifiable net assets acquired over implied value be treated?
Write a program that plays a tic-tac-toe game. : Using functional decomposition, write a program that plays a tic-tac-toe game.
Correct example of inheritance : Which of the following relationships is not a correct example of inheritance?  Parent to Children  Aunt to Uncle  Grandparent to Grandchild
What is a marketing information system : What is a marketing information system and what should it provide? How is the value of a marketing information system measured?
What is the change in the number of unemployed people : What is the change in the number of unemployed people in this particular month and what is the change in the number of  employed people  in the same period?
Competitive intelligence activities : What competitive intelligence activities can technology help a company to perform better? Are there limitations? Which ones will you choose for which industries? Explain

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create a graphical (not text-based) visual c++ program

Create a graphical (not text-based) Visual C++ program that allows the user to enter the coefficients for a system of four equations with four unknowns. Include a button that when clicked, will solve the system of equations and display the results in..

  By a minimal interpretation that makes a formula

By a minimal interpretation that makes a formula true, we mean that if one atom is removed from the interpretation then the resulting interpretation does no longer make the formula true.

  Write c program-visual studio to scan multiple text files

Write program in C or C++ and Visual Studio to scan multiple text files and count number of occurrences of each word in those files. Use binary tree to keep track of all words.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Write recursive boolean method to accept array and value

Write down the recursive boolean method named isMember. The method must accept two arguments: an array and a value. Method must return true if value is found in array.

  Design class for textbook-data field for grade level of book

Design a class named TextBook that is child class of Book. Include new data field for grade level of book. Create a displayTextBookInfo () method so that you can accommodate new grade-level field.

  Design in c a unix utility program gasp

Design in C a Unix utility program gasp. Command gasp [options] STRING FILE... must read listed files (FILE...) and copy each line from input to stdout if it contains STRING.

  Write program to count occurrences of each word in text

Write down C++ program to read following text. Count occurrences of each word in text and keep this count in list of elements containing (word, occurrence count) pairs.

  Design and write a c++11/fltk game program

The project is to design and write a C++11/FLTK game program with a graphical user interface. The game is based on "pancake sorting," which actually has some mathematical significance.

  Write a c++ program containing a linked list of 10 integer

Write a C++ program containing a linked list of 10 integer numbers. Have the program display the numbers in the list.

  Writing function that computes leap years

Write down function that computes leap years. Function prototype is as follows: Write function body which returns true if year is a leap year and false if year is not a leap year.

  Pros and cons of choosing two servers

Classify the two alternatives in terms of what type of application architecture they use. b. Outline the pros and cons of the two alternatives and make a recommendation to Fred about which is better.

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