#include class Kik{ public: mutable char *plansza; mutable int ilosc_wypisan; mutable int bledne_wywolania; static int errors; static int count; Kik(){ (*this).plansza = new char[9]; (*this).ilosc_wypisan = 0; (*this).bledne_wywolania = 0; count++; for(int i = 0; i < 9; i++){ (*this).plansza[i] = '.'; } } Kik(const Kik &A){ (*this).plansza = new char[9]; (*this).ilosc_wypisan = 0; (*this).bledne_wywolania = 0; count++; for(int i = 0; i < 9; i++){ (*this).plansza[i] = A.plansza[i]; } } Kik(char A[3][3]){ (*this).plansza = new char[9]; (*this).ilosc_wypisan = 0; (*this).bledne_wywolania = 0; count++; for(int i = 0; i < 3; i++){ for(int j = 0; j < 3; j++){ (*this).plansza[i * 3 + j] = A[i][j]; } } } ~Kik(){ errors -= (*this).bledne_wywolania; count--; } Kik operator=(Kik A){ if(this == &A) return *this; (*this).plansza = new char[9]; (*this).ilosc_wypisan = 0; (*this).bledne_wywolania = 0; for(int i = 0; i < 9; i++){ (*this).plansza[i] = A.plansza[i]; } return *this; } void playAt(int i, int j, char k) const { if(i >= 0 && i <= 2 && j >= 0 && j <= 2){ if(plansza[i * 3 + j] == '.' && (k == 'X' || k == 'O')){ (*this).plansza[i * 3 + j] = k; } else{ (*this).bledne_wywolania++; errors++; } } else{ (*this).bledne_wywolania++; errors++; } } int printNumber() const { return (*this).ilosc_wypisan; } static int errorNumber(){ return errors; } static int objectNumber(){ return count; } friend std::ostream& operator<<(std::ostream &stream, const Kik &A){ A.ilosc_wypisan++; for(int i = 0; i < 3; i ++){ for(int j = 0; j < 3; j++){ stream << A.plansza[i * 3 + j] << " "; } stream << std::endl; } return stream; } }; int Kik::errors = 0; int Kik::count = 0;