Repository navigation
Expand file tree
/
Copy pathmap.cpp
More file actions
93 lines (86 loc) · 1.67 KB
/
Copy pathmap.cpp
File metadata and controls
93 lines (86 loc) · 1.67 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "map.h"
#include "memtrace.h"
using namespace std;
void vonal(){
cout<<"+";
for(int i=1;i<=98;i++){
cout<<"-";
}
cout<<"+"<<endl;
}
int beolvas(ifstream &f, char c){
char kar=0;
String szam("");
while(f>>kar&&kar!=c){
szam+=kar;
}
return atoi(szam.c_str());
}
terkep::terkep(){
char c=0;
if(letezik()){
ifstream f;
f.open("map.txt",ios::in);
with=beolvas(f,'x');
height=beolvas(f);
String temp("");
abra=temp;
while(f>>c){
abra+=c;
}
abra+='\0';
f.close();
}
}
terkep::terkep(ifstream &f){
char c=0;
with=beolvas(f,'x');
height=beolvas(f);
String temp("");
abra=temp;
while(f>>c&&c!=';'){
abra+=c;
}
abra+='\0';
}
bool terkep::letezik(){
ifstream f;
f.open("map.txt",ios::in);
if(!f.is_open())
return false;
char c;
while(f>>c&&c!=';')
f>>c;
while(f>>c){
if(c=='#'||c=='@'||c=='F'||c=='h'||c=='m'||c=='M'||c=='_')
return false;
}
return true;
}
ostream& operator<<(ostream& os, const terkep& t){
vonal();
for(int i=0;t.abra[i]!='\0';i++){
if(i%t.with==0&&i!=0)
os<<endl;
switch(t.abra[i]){
case '_':os<<' ';
break;
case 'h':
case 'm':os<<'$';
break;
default:os<<t.abra[i];
break;
}
}
os<<endl;
vonal();
return os;
}
terkep& terkep::operator=(const terkep &t){
if (this != &t) {
abra=t.abra;
with=t.with;
height=t.with;
}
return *this;
}