Merhaba, C++ 'yı yeni öğrenmeye başladım ve sorunumda herhangi bir yardımın takdir edilmesi gerekiyor.Bir tac toe kodunun bir sınıf ile oluşturulmasını ancak sadece ekranın görüntülenmesi ve oynatıcının tanımlanması için
- ben bir oyun için bir kod parçası (seçilen tic tac toe)
- oluşturmak için istedi ama oldum onun iki kişi arasında bölünmüş. Benim rolüm sadece kartın görüntülenmesi ve oyuncu x veya oyuncunun seçimi için bir sınıf yaratmaktır. O.
Şimdiye kadar bu C++ kodunu oluşturmayı denedim ama hatalar göstermeye devam et, herkes bunu düzeltmeyi biliyor mu? Oyunda p.s XsandOs olarak sınıflandırdım.
#include <string>
#include <iostream>
using namespace std;
class XsandOs // Name of the class
{
public:
XsandOs();
void drawboard();
void printBoard();
void getMove(int move);
void choosePlayer(char player);
bool checkwinner(const char board[3][3], char symbol, int plays);
private:
const char board[3][3];
};
void XsandOs::drawboard // Develops the board
{
cout << "Let's play X's and O's\n" << "_________________________________\n\n"; //This prints a title declaring the name of the game
//This action uses an array to create the board, the user will choose the number to select where they want the character to go.
char board[3][3] =
{
{ '1', '2', '3', }; //This creates the top row
{'4', '5', '6', }; // This creates the middle row
{'7', '8', '9', }; // This creates the bottom row
};
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3; ++j)
{
cout << board[i][j] << "";
}
cout << endl;
}
}
void XsandOs::choosePlayer(char player)
{
if (player == 'X')
Player = 'O';
elseif(player == 'O')
Player = 'X';
return(void);
}
int main()
{
draw();
while (1)
{
input();
draw();
choosePlayer();
}
system("pause");
return 0;
}
Bunu daha önce görmüştüm ve size çok zaman kazandırabilir. "Kazanan tek hamle oynamak değildir." – user4581301
Ana() ve sınıf arasındaki bağlantıyı göremiyorum. Iostream için olandan önce bir '' 'koydunuz mu? – Christophe
'void XsandOs :: drawboard' void olmalıdır XsandOs :: drawboard()' – DimChtz