mirror of
https://gitflic.ru/project/w0lf/bulls-and-cows-cpp.git
synced 2026-03-29 00:12:46 +03:00
47 lines
796 B
C++
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;
|
|
}
|