SlideShare a Scribd company logo
1 of 6
Download to read offline
can someone add the main function to the code it keeps giving me error undefined winmain@16
here's the code:
#include <iostream>
#include <iomanip>
#include <random>
#include <ctime>
using namespace std;
enum status { WIN, DRAW, CONTINUE };
class ticTacToe
{
public:
void play();
private:
void displayBoard() const;
bool isValidMove(int row, int col) const;
bool getXOMove(char playerSymbol);
status gameStatus();
char board[3][3] = { {' ', ' ', ' '},
{' ', ' ', ' '},
{' ', ' ', ' '} };
int noOfMoves = 0;
};
void ticTacToe::play()
{
srand(time(0));
bool done = false;
char player;
if (rand() % 2 == 0) {
player = 'X';
}
else {
player = 'O';
}
displayBoard();
while (!done) {
done = getXOMove(player);
if (player == 'X') {
player = 'O';
}
else {
player = 'X';
}
}
}
void ticTacToe::displayBoard() const
{
cout << setw(3) << "1" << setw(3) << "2" << setw(3) << "3" << endl;
for (int row = 0; row < 3; row++) {
cout << setw(3) << row + 1;
for (int col = 0; col < 3; col++) {
cout << setw(3) << board[row][col];
}
cout << endl;
}
cout << endl;
}
bool ticTacToe::isValidMove(int row, int col) const
{
if (row < 0 || row > 2 || col < 0 || col > 2) {
return false;
}
if (board[row][col] != ' ') {
return false;
}
return true;
}
bool ticTacToe::getXOMove(char playerSymbol)
{
int row, col;
cout << "Player " << playerSymbol << ", enter your move (row column): ";
cin >> row >> col;
row--;
col--;
if (!isValidMove(row, col)) {
cout << "Invalid move. Please try again." << endl;
return false;
}
board[row][col] = playerSymbol;
noOfMoves++;
displayBoard();
status gameStatus = this->gameStatus();
if (gameStatus == WIN) {
cout << "Player " << playerSymbol << " wins!" << endl;
return true;
}
else if (gameStatus == DRAW) {
cout << "Game is a draw." << endl;
return true;
}
return false;
}
status ticTacToe::gameStatus()
{
for (int row = 0; row < 3; row++) {
if (board[row][0] != ' ' && board[row][0] == board[row][1] && board[row][1] ==
board[row][2]) {
return WIN;
}
}
for (int col = 0; col < 3; col++) {
if (board[0][col] != ' ' && board[0][col] == board[1][col] && board[1][col] == board[2][col]) {
return WIN;
}
}
if (board[0][0] != ' ' && board[0][0] == board[1][1] && board[1][1] == board[2][2]) {
return WIN;
}
if (board[2][0] != ' ' && board[2][0] == board[1][1] && board[1][1] == board[0][2]) {
return WIN;
}
if (noOfMoves == 9) {
return DRAW;
}
return CONTINUE;
}
}
can someone add the main function to the code it keeps giving me error.pdf

More Related Content

Similar to can someone add the main function to the code it keeps giving me error.pdf

ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfrajkumarm401
 
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdfimport java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdfaoneonlinestore1
 
NewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docx
NewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docxNewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docx
NewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docxcurwenmichaela
 
New Tools for a More Functional C++
New Tools for a More Functional C++New Tools for a More Functional C++
New Tools for a More Functional C++Sumant Tambe
 
#include stdio.h #include string.h #include stdlib.h #in.pdf
#include stdio.h #include string.h #include stdlib.h #in.pdf#include stdio.h #include string.h #include stdlib.h #in.pdf
#include stdio.h #include string.h #include stdlib.h #in.pdfsinghanubhav1234
 
GameOfLife.cs using System; using System.Collections.Generic;.pdf
GameOfLife.cs using System; using System.Collections.Generic;.pdfGameOfLife.cs using System; using System.Collections.Generic;.pdf
GameOfLife.cs using System; using System.Collections.Generic;.pdfaravlitraders2012
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdfkavithaarp
 

Similar to can someone add the main function to the code it keeps giving me error.pdf (9)

ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
 
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdfimport java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
 
NewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docx
NewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docxNewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docx
NewTetrisScore.cppNewTetrisScore.cpp newTetris.cpp  Defines t.docx
 
New Tools for a More Functional C++
New Tools for a More Functional C++New Tools for a More Functional C++
New Tools for a More Functional C++
 
201707 CSE110 Lecture 13
201707 CSE110 Lecture 13   201707 CSE110 Lecture 13
201707 CSE110 Lecture 13
 
project3
project3project3
project3
 
#include stdio.h #include string.h #include stdlib.h #in.pdf
#include stdio.h #include string.h #include stdlib.h #in.pdf#include stdio.h #include string.h #include stdlib.h #in.pdf
#include stdio.h #include string.h #include stdlib.h #in.pdf
 
GameOfLife.cs using System; using System.Collections.Generic;.pdf
GameOfLife.cs using System; using System.Collections.Generic;.pdfGameOfLife.cs using System; using System.Collections.Generic;.pdf
GameOfLife.cs using System; using System.Collections.Generic;.pdf
 
public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdf
 

More from aksachdevahosymills

Carbonate minerals have a lower saturation state in more acidic (lower.pdf
Carbonate minerals have a lower saturation state in more acidic (lower.pdfCarbonate minerals have a lower saturation state in more acidic (lower.pdf
Carbonate minerals have a lower saturation state in more acidic (lower.pdfaksachdevahosymills
 
Carbon monoxide (CO) competitively inhibits the binding of oxygen to h.pdf
Carbon monoxide (CO) competitively inhibits the binding of oxygen to h.pdfCarbon monoxide (CO) competitively inhibits the binding of oxygen to h.pdf
Carbon monoxide (CO) competitively inhibits the binding of oxygen to h.pdfaksachdevahosymills
 
Carbon fixation is part of a metabolic process in plants (either photo.pdf
Carbon fixation is part of a metabolic process in plants (either photo.pdfCarbon fixation is part of a metabolic process in plants (either photo.pdf
Carbon fixation is part of a metabolic process in plants (either photo.pdfaksachdevahosymills
 
Capn Company began the current period with a $44-000 credit baiance in.pdf
Capn Company began the current period with a $44-000 credit baiance in.pdfCapn Company began the current period with a $44-000 credit baiance in.pdf
Capn Company began the current period with a $44-000 credit baiance in.pdfaksachdevahosymills
 
Canada values regional economic integration- Choose two of these agree.pdf
Canada values regional economic integration- Choose two of these agree.pdfCanada values regional economic integration- Choose two of these agree.pdf
Canada values regional economic integration- Choose two of these agree.pdfaksachdevahosymills
 
Canadian travelers can apply for NEXUS cards which allow them to use d.pdf
Canadian travelers can apply for NEXUS cards which allow them to use d.pdfCanadian travelers can apply for NEXUS cards which allow them to use d.pdf
Canadian travelers can apply for NEXUS cards which allow them to use d.pdfaksachdevahosymills
 
can you write about BNF as a tool and how we had to change an incorrec.pdf
can you write about BNF as a tool and how we had to change an incorrec.pdfcan you write about BNF as a tool and how we had to change an incorrec.pdf
can you write about BNF as a tool and how we had to change an incorrec.pdfaksachdevahosymills
 
Can you think of any other CEO that advertises their company's product.pdf
Can you think of any other CEO that advertises their company's product.pdfCan you think of any other CEO that advertises their company's product.pdf
Can you think of any other CEO that advertises their company's product.pdfaksachdevahosymills
 
Can you please read the case and help me about the question of- -Do yo.pdf
Can you please read the case and help me about the question of- -Do yo.pdfCan you please read the case and help me about the question of- -Do yo.pdf
Can you please read the case and help me about the question of- -Do yo.pdfaksachdevahosymills
 
can you please answer all Questions Question 1 ( 16 points- 2 points.pdf
can you please answer all Questions  Question 1 ( 16 points- 2 points.pdfcan you please answer all Questions  Question 1 ( 16 points- 2 points.pdf
can you please answer all Questions Question 1 ( 16 points- 2 points.pdfaksachdevahosymills
 
can you please answer the blank based on the info below thanks Pease.pdf
can you please answer the blank based on the info below  thanks  Pease.pdfcan you please answer the blank based on the info below  thanks  Pease.pdf
can you please answer the blank based on the info below thanks Pease.pdfaksachdevahosymills
 
Can you help me!- I'm trying to create a chatroom using Java Script an.pdf
Can you help me!- I'm trying to create a chatroom using Java Script an.pdfCan you help me!- I'm trying to create a chatroom using Java Script an.pdf
Can you help me!- I'm trying to create a chatroom using Java Script an.pdfaksachdevahosymills
 
Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfaksachdevahosymills
 
Can you give me scientific papers that talk about Ways and methods of.pdf
Can you give me scientific papers that talk about Ways and methods of.pdfCan you give me scientific papers that talk about Ways and methods of.pdf
Can you give me scientific papers that talk about Ways and methods of.pdfaksachdevahosymills
 
Can you describe a time you acted with integrity- or someone you know.pdf
Can you describe a time you acted with integrity- or someone you know.pdfCan you describe a time you acted with integrity- or someone you know.pdf
Can you describe a time you acted with integrity- or someone you know.pdfaksachdevahosymills
 
Can you fix the errors- It isn't working when I try to run import s.pdf
Can you fix the errors- It isn't working when I try to run    import s.pdfCan you fix the errors- It isn't working when I try to run    import s.pdf
Can you fix the errors- It isn't working when I try to run import s.pdfaksachdevahosymills
 
Can you give me scientific papers that talk about a comparison between.pdf
Can you give me scientific papers that talk about a comparison between.pdfCan you give me scientific papers that talk about a comparison between.pdf
Can you give me scientific papers that talk about a comparison between.pdfaksachdevahosymills
 
Can someone help me with generating a frequency table please-(C++).pdf
Can someone help me with generating a frequency table please-(C++).pdfCan someone help me with generating a frequency table please-(C++).pdf
Can someone help me with generating a frequency table please-(C++).pdfaksachdevahosymills
 
can you analyze the five graphs and write comments about them Attach r.pdf
can you analyze the five graphs and write comments about them Attach r.pdfcan you analyze the five graphs and write comments about them Attach r.pdf
can you analyze the five graphs and write comments about them Attach r.pdfaksachdevahosymills
 
can you answer 1-3 pls 1- Study Power Point for Chapter 18- What gene.pdf
can you answer 1-3 pls  1- Study Power Point for Chapter 18- What gene.pdfcan you answer 1-3 pls  1- Study Power Point for Chapter 18- What gene.pdf
can you answer 1-3 pls 1- Study Power Point for Chapter 18- What gene.pdfaksachdevahosymills
 

More from aksachdevahosymills (20)

Carbonate minerals have a lower saturation state in more acidic (lower.pdf
Carbonate minerals have a lower saturation state in more acidic (lower.pdfCarbonate minerals have a lower saturation state in more acidic (lower.pdf
Carbonate minerals have a lower saturation state in more acidic (lower.pdf
 
Carbon monoxide (CO) competitively inhibits the binding of oxygen to h.pdf
Carbon monoxide (CO) competitively inhibits the binding of oxygen to h.pdfCarbon monoxide (CO) competitively inhibits the binding of oxygen to h.pdf
Carbon monoxide (CO) competitively inhibits the binding of oxygen to h.pdf
 
Carbon fixation is part of a metabolic process in plants (either photo.pdf
Carbon fixation is part of a metabolic process in plants (either photo.pdfCarbon fixation is part of a metabolic process in plants (either photo.pdf
Carbon fixation is part of a metabolic process in plants (either photo.pdf
 
Capn Company began the current period with a $44-000 credit baiance in.pdf
Capn Company began the current period with a $44-000 credit baiance in.pdfCapn Company began the current period with a $44-000 credit baiance in.pdf
Capn Company began the current period with a $44-000 credit baiance in.pdf
 
Canada values regional economic integration- Choose two of these agree.pdf
Canada values regional economic integration- Choose two of these agree.pdfCanada values regional economic integration- Choose two of these agree.pdf
Canada values regional economic integration- Choose two of these agree.pdf
 
Canadian travelers can apply for NEXUS cards which allow them to use d.pdf
Canadian travelers can apply for NEXUS cards which allow them to use d.pdfCanadian travelers can apply for NEXUS cards which allow them to use d.pdf
Canadian travelers can apply for NEXUS cards which allow them to use d.pdf
 
can you write about BNF as a tool and how we had to change an incorrec.pdf
can you write about BNF as a tool and how we had to change an incorrec.pdfcan you write about BNF as a tool and how we had to change an incorrec.pdf
can you write about BNF as a tool and how we had to change an incorrec.pdf
 
Can you think of any other CEO that advertises their company's product.pdf
Can you think of any other CEO that advertises their company's product.pdfCan you think of any other CEO that advertises their company's product.pdf
Can you think of any other CEO that advertises their company's product.pdf
 
Can you please read the case and help me about the question of- -Do yo.pdf
Can you please read the case and help me about the question of- -Do yo.pdfCan you please read the case and help me about the question of- -Do yo.pdf
Can you please read the case and help me about the question of- -Do yo.pdf
 
can you please answer all Questions Question 1 ( 16 points- 2 points.pdf
can you please answer all Questions  Question 1 ( 16 points- 2 points.pdfcan you please answer all Questions  Question 1 ( 16 points- 2 points.pdf
can you please answer all Questions Question 1 ( 16 points- 2 points.pdf
 
can you please answer the blank based on the info below thanks Pease.pdf
can you please answer the blank based on the info below  thanks  Pease.pdfcan you please answer the blank based on the info below  thanks  Pease.pdf
can you please answer the blank based on the info below thanks Pease.pdf
 
Can you help me!- I'm trying to create a chatroom using Java Script an.pdf
Can you help me!- I'm trying to create a chatroom using Java Script an.pdfCan you help me!- I'm trying to create a chatroom using Java Script an.pdf
Can you help me!- I'm trying to create a chatroom using Java Script an.pdf
 
Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdf
 
Can you give me scientific papers that talk about Ways and methods of.pdf
Can you give me scientific papers that talk about Ways and methods of.pdfCan you give me scientific papers that talk about Ways and methods of.pdf
Can you give me scientific papers that talk about Ways and methods of.pdf
 
Can you describe a time you acted with integrity- or someone you know.pdf
Can you describe a time you acted with integrity- or someone you know.pdfCan you describe a time you acted with integrity- or someone you know.pdf
Can you describe a time you acted with integrity- or someone you know.pdf
 
Can you fix the errors- It isn't working when I try to run import s.pdf
Can you fix the errors- It isn't working when I try to run    import s.pdfCan you fix the errors- It isn't working when I try to run    import s.pdf
Can you fix the errors- It isn't working when I try to run import s.pdf
 
Can you give me scientific papers that talk about a comparison between.pdf
Can you give me scientific papers that talk about a comparison between.pdfCan you give me scientific papers that talk about a comparison between.pdf
Can you give me scientific papers that talk about a comparison between.pdf
 
Can someone help me with generating a frequency table please-(C++).pdf
Can someone help me with generating a frequency table please-(C++).pdfCan someone help me with generating a frequency table please-(C++).pdf
Can someone help me with generating a frequency table please-(C++).pdf
 
can you analyze the five graphs and write comments about them Attach r.pdf
can you analyze the five graphs and write comments about them Attach r.pdfcan you analyze the five graphs and write comments about them Attach r.pdf
can you analyze the five graphs and write comments about them Attach r.pdf
 
can you answer 1-3 pls 1- Study Power Point for Chapter 18- What gene.pdf
can you answer 1-3 pls  1- Study Power Point for Chapter 18- What gene.pdfcan you answer 1-3 pls  1- Study Power Point for Chapter 18- What gene.pdf
can you answer 1-3 pls 1- Study Power Point for Chapter 18- What gene.pdf
 

Recently uploaded

Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

can someone add the main function to the code it keeps giving me error.pdf

  • 1. can someone add the main function to the code it keeps giving me error undefined winmain@16 here's the code: #include <iostream> #include <iomanip> #include <random> #include <ctime> using namespace std; enum status { WIN, DRAW, CONTINUE }; class ticTacToe { public: void play(); private: void displayBoard() const; bool isValidMove(int row, int col) const; bool getXOMove(char playerSymbol); status gameStatus(); char board[3][3] = { {' ', ' ', ' '}, {' ', ' ', ' '}, {' ', ' ', ' '} }; int noOfMoves = 0; }; void ticTacToe::play()
  • 2. { srand(time(0)); bool done = false; char player; if (rand() % 2 == 0) { player = 'X'; } else { player = 'O'; } displayBoard(); while (!done) { done = getXOMove(player); if (player == 'X') { player = 'O'; } else { player = 'X'; } } } void ticTacToe::displayBoard() const {
  • 3. cout << setw(3) << "1" << setw(3) << "2" << setw(3) << "3" << endl; for (int row = 0; row < 3; row++) { cout << setw(3) << row + 1; for (int col = 0; col < 3; col++) { cout << setw(3) << board[row][col]; } cout << endl; } cout << endl; } bool ticTacToe::isValidMove(int row, int col) const { if (row < 0 || row > 2 || col < 0 || col > 2) { return false; } if (board[row][col] != ' ') { return false; } return true; } bool ticTacToe::getXOMove(char playerSymbol) { int row, col;
  • 4. cout << "Player " << playerSymbol << ", enter your move (row column): "; cin >> row >> col; row--; col--; if (!isValidMove(row, col)) { cout << "Invalid move. Please try again." << endl; return false; } board[row][col] = playerSymbol; noOfMoves++; displayBoard(); status gameStatus = this->gameStatus(); if (gameStatus == WIN) { cout << "Player " << playerSymbol << " wins!" << endl; return true; } else if (gameStatus == DRAW) { cout << "Game is a draw." << endl; return true; } return false; } status ticTacToe::gameStatus()
  • 5. { for (int row = 0; row < 3; row++) { if (board[row][0] != ' ' && board[row][0] == board[row][1] && board[row][1] == board[row][2]) { return WIN; } } for (int col = 0; col < 3; col++) { if (board[0][col] != ' ' && board[0][col] == board[1][col] && board[1][col] == board[2][col]) { return WIN; } } if (board[0][0] != ' ' && board[0][0] == board[1][1] && board[1][1] == board[2][2]) { return WIN; } if (board[2][0] != ' ' && board[2][0] == board[1][1] && board[1][1] == board[0][2]) { return WIN; } if (noOfMoves == 9) { return DRAW; } return CONTINUE; } }