Skip to content

Instantly share code, notes, and snippets.

@charleswvs
Created October 17, 2017 20:33
Show Gist options
  • Save charleswvs/88334f81607ed94ba4bf8016b0263c23 to your computer and use it in GitHub Desktop.
Save charleswvs/88334f81607ed94ba4bf8016b0263c23 to your computer and use it in GitHub Desktop.
Udemy Course - Unreal_Section01_class29
#include "stdafx.h"
#include "fbull.h"
FBullCowGame::FBullCowGame()
{
}
void FBullCowGame::Reset()
{
}
int FBullCowGame::GetMaxTries()
{
return MyMaxTries;
}
int FBullCowGame::GetCurrentTry()
{
return 0;
}
bool FBullCowGame::IsGameWon()
{
return false;
}
bool FBullCowGame::CheckGuess()
{
return false;
}
#pragma once
class FBullCowGame
{
public:
FBullCowGame::FBullCowGame();//constructor
int GetMaxTries();//era pra deixar constante, mas eu fiquei com preguiça
int GetCurrentTry();//era pra deixar constante, mas eu fiquei com preguiça
bool IsGameWon();//era pra deixar constante, mas eu fiquei com preguiça
bool CheckGuess(); //fazer retornar um valor mais rico
void Reset();
private:
int MyCurrentTry = 1;
int MyMaxTries = 5;
};
/*PLZ IGNORE THE COMMENTS*/
// section01.cpp: Define o ponto de entrada para a aplicação de console.
//pesquisar sobre std::string, void.
//NAO SEI ONDE ESTA DECLARADO O DIABO DO BCGame
#include "fbull.h"
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <string>
void introduction();
void playgame();
std::string guess();
bool AskToPlayAgain();
FBullCowGame BCGame;
int main()
{
do
{
introduction();
playgame();
}
while (AskToPlayAgain() == true);
std::cout << "\n Thanks for playing =) " << std::endl;
return 0; //sair da aplicação
}
//iniciar o loop "for"
void playgame()
{
//EU TE ODEIO CLASSE
int MaxTries = BCGame.GetMaxTries();
//repetindo a mesma pergunta
/*constexpr int LIMIT = 5; ESSA PORRA FUNCIONA MAS O VIDEO QUER A DROGA DO CABECALHO*/
for (int count = 1; count <= MaxTries; count++)
{
guess();
}
}
//introdução ao jogo
void introduction()
{
constexpr int WORD_LENGHT = 5;
std::cout << "\n Welcome to bulls and cows, a fun word game. \n";
std::cout << "Can you guess the " << WORD_LENGHT << " letter isogram I am thinking of? \n\n";
return;
}
//pegue o palpite do jogador
std::string guess()
{
std::string guess = "";
std::cout << "Tell me your guess: ";
std::getline(std::cin, guess);//std::getline pega toda a linha
std::cout << "Your guess was: " << guess << std::endl << std::endl;
return guess;
}
//pergunte se quer jogar novamente
bool AskToPlayAgain()
{
std::cout << "\n Do you want to play again? (y/n) ";
std::string awnser = "";
std::getline(std::cin, awnser);
return (awnser[0] == 'y' || awnser[0] == 'Y');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment