-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlight.cpp
More file actions
110 lines (87 loc) · 2.48 KB
/
Flight.cpp
File metadata and controls
110 lines (87 loc) · 2.48 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
94
95
96
97
98
99
100
101
/*
@author Saitcan Baskol
@studentid 21803589
*/
#include <iostream>
#include <string>
using namespace std;
#include "Flight.h"
Flight::Flight()
{
flightNumber = 0;
row = 2;
seat = 2;
seatReserv = new bool*[row];
for(int i = 0; i < row;i++)
{
seatReserv[i] = new bool[seat];
for(int j = 0;j < seat; j++)
{
seatReserv[i][j] = true;
}
}
}
Flight::Flight(int fly,int rw,int st)
{
flightNumber = fly;
row = rw;
seat = st;
seatReserv = new bool*[row];
for(int i = 0; i < row;i++)
{
seatReserv[i] = new bool[seat];
for(int j = 0;j < seat; j++)
{
seatReserv[i][j] = true;
}
}
}
Flight::~Flight()
{
for(int i = 0; i < row; i++)
{
delete[] seatReserv[i];
}
delete [] seatReserv;
}
Flight::Flight(const Flight& rightVal)
{
flightNumber = rightVal.flightNumber;
row = rightVal.row;
this->seatReserv = new bool*[row];
for (int i = 0; i < this->row; i++)
{
this->seatReserv[i] = new bool[seat];
for (int j = 0; j < this->seat; j++)
{
this->seatReserv[i][j] = rightVal.seatReserv[i][j];
}
}
}
Flight& Flight::operator=(const Flight& rightVal)
{
if(this != &rightVal)
{
for(int i = 0; i < row; i++)
{
delete[] seatReserv[i];
}
delete [] seatReserv;
flightNumber = rightVal.flightNumber;
row = rightVal.row;
seat = rightVal.seat;
seatReserv = new bool*[row];
for(int r = 0; r < row; r++)
{
seatReserv[r] = new bool[seat];
}
for(int k = 0; k < row; k++)
{
for(int m = 0; m < seat; m++)
{
seatReserv[k][m] = rightVal.seatReserv[k][m];
}
}
}
return *this;
}