Files
bulls-and-cows-cpp/bulls-and-cows-cpp/CGame.h
2023-08-02 15:22:21 +03:00

47 lines
796 B
C++

// CGame.h
//
#pragma once
#include "defines.h"
#include "CUserInput.h"
#include "CStep.h"
class CGame
{
private:
int m_ucDigits = 4; // Number of digits into the guessed number
int m_ucBulls;
int m_ucCows;
bool m_fGameIsEnd;
int m_uStepCounter;
int* m_uGuessedNumber;
std::wstring m_sLastError;
std::vector<CStep> m_Steps;
int GetNumber(CStep);
void ShowGuessedNumber(bool);
void PrintGameHeader();
void PrintGameFooter();
void PrintSteps();
template<typename T, typename N>
bool IsEqual(const T, const N, int);
public:
void Init();
void Start();
CGame();
~CGame();
};
template<typename T, typename N>
bool CGame::IsEqual(const T number, const N digit, int i)
{
bool result = false;
while ((--i) >= 0)
{
if (digit == number[i]) result = true;
}
return result;
}