Solved

Help understanding class using a simple game

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now