-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirection.h
115 lines (100 loc) · 2.25 KB
/
direction.h
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#pragma once
#include"plane.h"
#include<string>
#include<vector>
#include<iostream>
/*!
\brief Main class of project, consist realisation of object Direction.
Connect with class Plane with function SetPlane and function SkipTime skip time in programm.
*/
class Direction {
private:
std::string name;
int start;
int end;
int dist;
int time;
int plane;
public:
Direction() {
plane = -1;
time = 0;
dist = 0;
}
Direction(std::string name, int start, int end) : name(name), start(start), end(end) {
plane = -1;
time = 0;
dist = 0;
}
friend std::ostream& operator<< (std::ostream& out, const Direction& direction)
{
out << direction.name << endl << direction.start << endl << direction.end << endl << direction.dist << endl << direction.time;
return out;
}
friend std::istream& operator>> (std::istream& is, Direction& direction)
{
is >> direction.name >> direction.start >> direction.end;
return is;
}
void SetName(std::string s) {
this->name = s;
}
std::string GetName() {
return this->name;
}
void SetStart(int i) {
this->start = i;
}
int GetStart() {
return this->start;
}
void SetEnd(int i) {
this->end = i;
}
int GetEnd() {
return this->end;
}
void SetPlane(int id) {
this->plane = id;
}
int GetPlane() {
return this->plane;
}
void skipTime(std::vector<Plane> pl, int t) {
if (plane!=-1) {
this->dist = (this->time+t)*pl[plane].GetSpeed();
this->time += t;
}
}
bool checkEnd() {
return (this->end - this->start) <= dist;
}
void print() {
cout << "Name: " << this->name << endl;
cout << "Start coord: " << this->start << endl;
cout << "End coord: " << this->end << endl;
cout << "Distance: " << this->dist << endl;
cout << "Time: " << this->time << endl;
cout << "Plane ID: " << this->plane << endl;
}
~Direction() {
}
};
/*!
\brief Wrapper class which work with class Direction, ñonsist vector<Direction> and functions to work with them.
*/
class direction_Menu {
private:
public:
vector<Direction> vec;
void findDirectionByName(string fname);
void editName(int index, string name);
void pushFront(string name, int start, int end);
void print();
void readFile(string fileName);
void printFile(string fileName);
void del(int index);
size_t size() {
return vec.size();
}
};