Solved

Help understanding class using a simple game

Posted on 1998-03-11
1
182 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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.

752 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