-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plane.h
93 lines (74 loc) · 1.78 KB
/
Plane.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
#pragma once
#include <iostream>
#include <iomanip>
using namespace std;
class Plane
{
int id;
int deadLineTime;//unit time (or fuel)
int entryTime;
public:
Plane() :id(-2), deadLineTime(-1),entryTime(-1){} //-1=> no data is assigned yet
Plane(int _id, int _entrytime, int _dealLineTime) :id(_id), deadLineTime(_dealLineTime), entryTime(_entrytime){}
int getId(){ return this->id;}
void setId(int _id){ this->id=_id; }
void setFuel(int a){ deadLineTime=a; }
// > , < BEHAVIOUR OF THIS FUNCTION DEPENDS ON OUR NEED
bool operator>(const Plane & RHS)
{
if (this->deadLineTime > RHS.deadLineTime)
return true;
return false;
}
void Print()
{
cout << "ID: " << id;
cout << " & Entry: " << entryTime<< endl;
cout << " & Dead line : " << deadLineTime << endl;
}
int getSecondTime()
{
return deadLineTime;
}
int getFirstTime()
{
return entryTime;
}
void printToFile(ofstream & out)
{
out << " (id=" << id;
// out << "," << std::setw(3) << (deadLineTime) ;
out<< ")";
}
friend bool operator>(const Plane & LHS, const Plane & RHS);
void operator=(const Plane RHS)
{
this->id = RHS.id;
this->deadLineTime = RHS.deadLineTime;
this->entryTime = RHS.entryTime;
}
bool operator<=(const Plane RHS)
{
if (this->id == RHS.id && this->deadLineTime == RHS.deadLineTime && this->entryTime == RHS.entryTime)
return true;
else if (this->deadLineTime < RHS.deadLineTime)
return true;
return false;
}
friend ostream& operator<<(ostream& os, const Plane& dt);
~Plane()
{
//NOTHING TO DELET
}
};
ostream& operator<<(ostream& os, const Plane& dt)
{
cout << " (" << dt.id << "," << dt.deadLineTime << ") ";
return os;
}
bool operator>(const Plane & LHS, const Plane & RHS)
{
if (LHS.deadLineTime > RHS.deadLineTime)
return true;
return false;
}