-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
78 lines (58 loc) · 2.36 KB
/
Game.cpp
File metadata and controls
78 lines (58 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/****************************************************************************************************
* * Program name: CS162 Group Project
* * Group number: # 29
* * Group member: Taekyoung Kim, Zuhair Ahmed
* * Date: 02/10/2019
* * Description: This is Game.cpp file for CS162 GroupProject
* * This project demonstrates a 2D simulation of Predator-Prey Game.
* * The board is a 2D array and each cell points to a Critter.
******************************************************************************************************/
#include "Game.h"
#include "GBoard.h"
#include "Critter.h"
#include "Ant.h"
#include "DoodleBug.h"
#include "inputVal.h"
#include <climits>
#include <iostream>
Game::Game() = default;
Game::~Game() = default;
void Game::play(){
GBoard gB;
Critter*** board = gB.setBoard();
double oNum;
int numb;
int cont;
int pAgain;
std::cout<<"Welcome to the ants and doodle bugs' Predator-Prey simulation world"<<std::endl;
std::cout<<"If you input the number of days that you want to go, you can see it"<<std::endl;
std::cout<<"You can continue after the simulation ends, ";
std::cout<<"and also you can stop, new start, or even exit at that time. Now, let's begin."<<std::endl;
do {
gB.fillBoard(board);
do {
std::cout << "How many days you want to go? please input your number: ";
std::cin >> oNum;
numb = inputVal(oNum);
for (int i = 0 ; i < numb ; i++) {
std::cout<<"Round: "<<i+1<<std::endl;
gB.displayBoard(board);
gB.oneLotate(board);
std::cout << std::endl;
}
std::cin.clear();
std::cin.ignore(INT_MAX, '\n');
std::cout << "If you want to continue, input 1. Otherwise, click any keys! ";
std::cin >> cont;
std::cout << "----------------------------------------------------" << std::endl;
} while (cont == 1);
std::cout << "So you want to stop. Let's stop!" << std::endl;
std::cout<<std::endl;
std::cin.clear();
std::cin.ignore(INT_MAX, '\n');
std::cout<<"If you want to play from the beginning. Please input 1. Otherwise, click any keys! ";
std::cin>>pAgain;
}while(pAgain ==1);
std::cout<<"You want to exit. Okay Good bye!" << std::endl;
gB.deleteBoard(board);
}