-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnvironment.cpp
More file actions
52 lines (44 loc) · 1.22 KB
/
Environment.cpp
File metadata and controls
52 lines (44 loc) · 1.22 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
/*
* File: Environment.cpp
* Author: Артём
*
* Created on 14 Май 2016 г., 16:39
*/
#include "Environment.h"
Environment::Environment() {}
Environment::istream& operator >> (Environment::istream& input, Environment& env){
typedef Environment::PointE PointE;
typedef Environment::LineE LineE;
PointE firstPt;
bool firstPointRead = false;;
while(!input.eof()){
PointE p1;
PointE p2;
input >> p1;
if(!firstPointRead)
firstPt = p1;
firstPointRead = true;
if(!input.eof())
input >> p2;
else
p2 = firstPt;
if(!(p1 == p2))
env.getWalls().push_back(LineE(p1,p2));
}
return input;
}
Environment::ostream& operator <<(Environment::ostream& output, Environment& env){
for(auto line: env.getWalls()){
output << line << " with equation ";
if(line.isVertical())
output << "x = " << line.p1.x << "\n";
else
output << "y = " << line.GetK() << "*x" << (line.GetB() < 0 ? " " : " +") << line.GetB() << "\n";
}
return output;
}
Environment::Environment(const Environment& orig) {
env = orig.getWalls();
}
Environment::~Environment() {
}