-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsweeper.cpp
More file actions
34 lines (32 loc) · 947 Bytes
/
Copy pathsweeper.cpp
File metadata and controls
34 lines (32 loc) · 947 Bytes
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
#include <iostream>
#include <cstdlib>
#include "node.h"
#include "MineBoard.h"
using namespace std;
int main(int argc, char** argv){
int width=atoi(argv[1]);
int height=atoi(argv[2]);
int mines_n=atoi(argv[3]);
if(argc!=4||(width*height)<=mines_n) {cout<<"Wrong arguments!"<<endl;return 0;}
char again='y';
cout<<"initiation begin!"<<endl;
MineBoard M(width,height,mines_n); //initialize Board
cout<<"initiation complete!"<<endl;
M.showBoard();
while(again=='y'){
while(!M.isfailure()&&!M.isWin()){
M.getCoordinate(); //the coordinate need to uncover
M.applyChanges();
M.showBoard();
}
if(M.isfailure()){cout<<"You lose!"<<endl;}
if(M.isWin()){cout<<"You win!"<<endl;}
cout<<"Want new game?(y/n)"<<" ";
cin>>again;
if(again=='y'){
M.reSet();
M.showBoard();
}
}
return 0;
}