-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevel.cc
executable file
·54 lines (39 loc) · 886 Bytes
/
Level.cc
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
#include "Level.h"
#include <string>
#include <ctime>
#include <fstream>
using namespace std;
Level::Level(int lev, string fileName):
level{lev}, fileName{fileName}, random{true}{}
int Level::getLevel() { return level; }
Level::~Level() {
if(!random) file.close();
}
bool Level::isRandom(){ return random; }
void Level::setRandom(){
if(random) return;
random = true;
file.close();
}
void Level::setFile(string newFile){ fileName = newFile; }
void Level::removeRandom(){
if(!random) return;
random = false;
file.open(fileName);
}
char Level::readFromFile(){
char ch;
while (true){
ch = file.get();
if(ch == EOF){
file.clear();
file.seekg(0, ios::beg);
ch = file.get();
}
if(ch == 'L' || ch == 'I' || ch == 'J' || ch == 'O' ||
ch == 'S' || ch == 'Z' || ch == 'T' || ch == '*' || ch == 'N'
|| ch == 'C') break;
continue;
}
return ch;
}