Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help understanding class using a simple game

Posted on 1998-03-11
1
Medium Priority
?
187 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
1 Comment
 
LVL 3

Accepted Solution

by:
q2guo earned 400 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

963 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