#include <iostream> // 콘솔 입출력
#include <stdlib.h> // 랜덤 모듈
#include <time.h> // 타임 추출
#include <string>
#include <CoreWindow.h>
using namespace std;
class LottoGame{
public:
int resultNum[6];// 결정된 6개의 숫자를 담을 배열.
int playNum = 0; // 현재 뽑힌 번호를 담을 변수
int findNum = 0;
int aniSpeed;
int gamePlayNum;
string GameTextAni;
void textAni(){
GameTextAni = "WELCOME TO THE LOTTO GAME! ENJOY YOUR LIFE!";
cout << "= ";
for (int i = 0; i < 43; i++){
cout << GameTextAni[i];
Sleep(50);
}
cout << " =" << endl;
}
void GameIntro(){
int introSpeed = 250;
cout << "========================================================================" << endl;
Sleep(introSpeed);
cout << "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiE" << endl;
Sleep(introSpeed);
cout << "E E" << endl;
Sleep(introSpeed);
cout << "E E" << endl;
Sleep(introSpeed);
cout << "E +EEE` EEEo oEEE `E" << endl;
Sleep(introSpeed);
cout << "E EEE+ .;i++++i;` OEEE8EEEEEEE8EEEE8 `I+oOOOo=. `E" << endl;
Sleep(introSpeed);
cout << "E iE8E` ~i+iiI;=iii+~o+E888+++i8E8E+++;+OOoiI=oooO; `E" << endl;
Sleep(introSpeed);
cout << "E EEEo I+ii. ~+iiI :E8E~ E8Ei .oooI oooo `E" << endl;
Sleep(introSpeed);
cout << "E =E8E` .+ii: :ii+. 8EE8 iE8E Oooi `ooOI `E" << endl;
Sleep(introSpeed);
cout << "E EE8E;` `;iii= `I+i+: :EEE: E8E+ `Oooo. `;ooO= `E" << endl;
Sleep(introSpeed);
cout << "E =EEEEEEEEE =+ii+++++iI oEEEEEEI;EEEEEEI:OooOOOOOO+. `E" << endl;
Sleep(introSpeed);
cout << "E ~;====I: `~;;;;:. ~I==II .;===I :;III;~ `E" << endl;
Sleep(introSpeed);
cout << "E E" << endl;
Sleep(introSpeed);
cout << "E E" << endl;
Sleep(introSpeed);
cout << "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiE" << endl;
Sleep(introSpeed);
cout << "========================================================================" << endl;
Sleep(introSpeed);
cout << "= =" << endl;
Sleep(introSpeed);
textAni();
Sleep(introSpeed);
cout << "= =" << endl;
Sleep(introSpeed);
cout << "========================================================================" << endl;
cout << " " << endl;
}
int RollNumver(){
int Roll = rand() % 45 + 1;
return Roll;
}
void InputNumber(){
int i = 0;
for (i; i < 6; i++){
playNum = RollNumver(); // 6번 반복하면서 랜덤한 숫자를 playNum에 넣어주고
// cout << i << "번째 번호 : "<<playNum << endl;
// Sleep(1000);
resultNum[i] = playNum; // 입력된 playNum 번호를 배열의[i]번째에 넣어준다.
for (int j = 0; j < i; j++){ // 반복된 숫자 체크
if (resultNum[j] == playNum){ // i번째 배열에 들어간 수가 playnum과 같으면 반복문을 재 실행 하도록 한다.
//cout << playNum << endl;
//cout << i << "번째 번호 : " << playNum << "반복이므로 다시 체크 합니다." << endl;
i = i - 1;
}
}
}
}
void printNumber(){
cout << "======================================================================== " << endl;
for (int i = 0; i < 6; i++)
{
cout << "[" << i + 1 << "]" << " 번째 번호를 뽑고 있습니다";
Ani("ㆍ", aniSpeed);
Ani("ㆍ", aniSpeed);
Ani("ㆍ", aniSpeed);
cout << " ==> " << resultNum[i] << " 번!!" << endl;
}
cout << "======================================================================== " << endl;
cout << "금주의 로또당첨 번호는 ";
for (int i = 0; i < 6; i++){
cout << "[" << resultNum[i] << "] ";
}
cout << "입니다! y(^o^)yeah" << endl;
cout << "------------------------------------------------------------------------ " << endl;
cout << "" << endl;
}
void Ani(string chr, int time){ //Loading 애니메이션
cout << chr;
Sleep(time);
}
void GameMain(){
GameIntro();
while (true){
cout << "로또 게임을 진행 하시겠습니까? ( 1:진행, 2:종료 ) ==> ";
cin >> gamePlayNum;
if (gamePlayNum == 1){ InputNumber(); printNumber(); }
else if (gamePlayNum == 2){
cout << "게임을 종료 합니다. 당신은 럭키가이!!!" << endl;
break;
}
else {
cout << "진행과 종료 중에서 선택 해주세요." << endl;
continue;
}
}
}
};
void main(){
srand((unsigned int)time(NULL));
LottoGame myLottoGame;
myLottoGame.aniSpeed = 500;
myLottoGame.GameMain();
}
댓글
댓글 쓰기