Solved

Help understanding class using a simple game

Posted on 1998-03-11
1
183 Views
Last Modified: 2010-04-10
I am trying to make a tic tac toe program using the members listed . Please help me pick it apart my Mentor is
on holiday and I have nowhere else to turn.

enum Player { x, o, empty };

class Board
{
      public:
      int Board (column, row)

            typedef BoardSize [column] [row]

       void Place (Player,column,row)
                  cout << " Please enter your marker " << flush;
                  cin >> char Player
                  cout << " Please enter a column " <<
                          << " and row to place your marker " << flush;
                  cin >> int column, int row;
                              if (Board [column], [row] = empty ){
                                    cout << P << " is entered at " << Board [ column ], [row]<<endl;
                                    else cout << " That space is full " << endl;



       int Win (Player)
                  while Board [column], [row] = Player;
                              ++row;
                                    if row = 3;
                                    cout << Player << " wins " << endl;
              else if Board [column], [row] = Player;
                               ++column;
                                    if column = 3;
                                    cout << Player << " wins " << endl;
              else if Board [column], [row] = Player;
                              ++column, ++row;
                                     if column && row = 3;
                                     cout << Player << " wins " << endl;


       int StaleMate(Player)
              if Board [], [] != empty && Win() = 0;
              cout << " The match is a Stalemate " << endl;


             }


              int main()
              {
                  const int column = 3;
                  const int row = 3;
                   Player x;
                   Player o;

              return 0;
              }
0
Comment
Question by:chasa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
q2guo earned 200 total points
ID: 1183374
I modified you code a bit.  It 's still far from perfect, but it should get you started in the right direction.
------------------------------------------------------------


#include <iostream.h>

enum Player { x, o, empty };

class Board
{

int column;
int row;
int *grid;

public:
    int Board(int, int);
    ~Board() { delete grid; }
    void Place(void);
    int Win(void);
    void Print_result(void);
    int isBoardFull();
}

Board::Board(int column, int row)
{
    grid = new int [column*row];
    for (int i=0; i < column*row; i++) {
     // initialize board
    }
}

int Board::Print_result(Player)
    if (Player == o) cout << "O wins" <<endl;
    else if (Player == x) cout << "x wins" <<endl;
    else cout << " The match is a Stalemate " << endl;
}

int Board::isBoardFull()
{
   // return 1 is board is full
}

int Board::Win(void)
{
    while Board [column], [row] = Player;
    ++row;
    if row = 3;
    cout << Player << " wins " << endl;
      else if Board [column], [row] = Player;
    ++column;
    if column = 3;
    cout << Player << " wins " << endl;
      else if Board [column], [row] = Player;
    ++column, ++row;
    if column && row = 3;
    cout << Player << " wins " << endl;
}

void Board::Place ()
{
    cout << " Please enter your marker " << flush;
    cin >> char Player
    cout << " Please enter a column " <<
      << " and row to place your marker " << flush;
    cin >> int column, int row;
    if (Board [column], [row] = empty ){
    cout << P << " is entered at " << Board [ column ], [row]<<endl;
    else cout << " That space is full " << endl;
}

int main()
{
    const int column = 3;
    const int row = 3;
    Player player1 = x;
    Player player2 = o;
    Board b(column, row);

    while (!(b.isBoardFull()))
    {



    }
    b.Print_result(Win());

    return 0;
}
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question