-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVovaFlightTester.java
More file actions
156 lines (134 loc) · 9.82 KB
/
VovaFlightTester.java
File metadata and controls
156 lines (134 loc) · 9.82 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
public class VovaFlightTester
{
public static void main(String args[])
{
//Copy Constructor aliasing check.
System.out.println("==========================================");
System.out.println("COPY CONSTRUCTOR ALIASING CHECK.");
System.out.println("==========================================");
Flight firstFlight = new Flight("London","TLV",12,15,400,45,1000);
Flight secondFlight = new Flight(firstFlight);
secondFlight.setPrice(3000);
System.out.println("first flight price: " +firstFlight.getPrice()+" Need to be 1000");
System.out.println("second flight price: " +secondFlight.getPrice()+" Need to be 3000");
secondFlight.setPrice(1000);
//getArrival aliasing check.
System.out.println("==========================================");
System.out.println("GETARRIVAL ALIASING CHECK.");
System.out.println("==========================================");
secondFlight.setFlightDuration(500);
System.out.println("The arrival time of the first flight: " +firstFlight.getArrivalTime()+" Need to be 18:55");
System.out.println("The arrival time of the second flight: " +secondFlight.getArrivalTime() +" Need to be 20:35");
secondFlight.setFlightDuration(400);
//setDeparture aliasing check.
System.out.println("==========================================");
System.out.println("SETDEPARTURE ALIASING CHECK.");
System.out.println("==========================================");
Time1 depTemp = new Time1(10,15);
secondFlight.setDeparture(depTemp);
depTemp.setHour(20);
depTemp.setMinute(20);
System.out.println("The departure time of the first flight: " +firstFlight.getDeparture()+ " Need to be 12:15");
System.out.println("The departure time of the second flight: " +secondFlight.getDeparture() + " Need to be 10:15");
depTemp.setHour(12);
depTemp.setMinute(15);
secondFlight.setDeparture(depTemp);
//getDestination aliasing check.
System.out.println("==========================================");
System.out.println("GETDESTINATION ALIASING CHECK.");
System.out.println("==========================================");
String destTemp = secondFlight.getDestination();
destTemp = "Dublin";
System.out.println("The destination of the second flight: " +secondFlight.getDestination()+ " Need to be TLV");
//getOrigin aliasing check
System.out.println("==========================================");
System.out.println("GETORIGIN ALIASING CHECK");
System.out.println("==========================================");
destTemp = secondFlight.getOrigin();
destTemp = "Dublin";
System.out.println("second flight origin: " +secondFlight.getOrigin()+" Need to be London");
//getDeparture aliasing check.
System.out.println("==========================================");
System.out.println("GETDEPARTURE ALIASING CHECK.");
System.out.println("==========================================");
Time1 depTimeSet = secondFlight.getDeparture();
depTimeSet.setHour(20);
depTimeSet.setMinute(20);
System.out.println("The departure time of the second flight: " +secondFlight.getDeparture() + " Need to be 12:15");
//setDestination aliasing check.
System.out.println("==========================================");
System.out.println("SETDESTINATION ALIASING CHECK.");
System.out.println("==========================================");
String destTempSet = "Rio";
secondFlight.setDestination(destTempSet);
destTempSet = "L.A";
System.out.println("The destination of the second flight: " +secondFlight.getDestination()+ " Need to be Rio");
secondFlight.setDestination("TLV");
//setOrigin aliasing check
System.out.println("==========================================");
System.out.println("setOrigin aliasing check");
System.out.println("==========================================");
String originTempSet = "Jerusalem";
secondFlight.setOrigin(originTempSet);
originTempSet="Haifa";
System.out.println("second flight origin: " +secondFlight.getOrigin()+ " Need to be Jerusalem");
secondFlight.setOrigin("London");
//addPassengers,setNoOfPassengers,isFull,toString and getPassengers test.
System.out.println("==========================================");
System.out.println("addPassengers,setNoOfPassengers,isFull,toString and getPassengers test");
System.out.println("==========================================");
System.out.println("The number of passangers of the second flight: " +secondFlight.getNoOfPassengers());
System.out.println("Were 200 passengers added?: " +secondFlight.addPassengers(200)+" Need to be true");
System.out.println("The number of passangers of the second flight: " +secondFlight.getNoOfPassengers()+" Need to be 245");
System.out.println(secondFlight);
System.out.println("Were 5 passengers added?: " +secondFlight.addPassengers(5)+" Need to be true");
System.out.println("The number of passangers of the second flight: " +secondFlight.getNoOfPassengers()+" Need to be 250");
System.out.println(secondFlight);
System.out.println("Were 10 passengers added?: " +secondFlight.addPassengers(10)+" Need to be false");
System.out.println("The number of passangers of the second flight: " +secondFlight.getNoOfPassengers()+" Need to be 250");
System.out.println(secondFlight);
System.out.println("second flight full?: " +secondFlight.getIsFull()+" Need to be true");
secondFlight.setNoOfPassengers(249);
System.out.println("The number of passangers of the second flight: " +secondFlight.getNoOfPassengers()+" Need to be 249");
System.out.println("second flight full?: " +secondFlight.getIsFull()+" Need to be false");
secondFlight.setNoOfPassengers(-1);
System.out.println("The number of passangers of the second flight: " +secondFlight.getNoOfPassengers()+" Need to be 249");
secondFlight.setNoOfPassengers(0);
System.out.println("The number of passangers of the second flight: " +secondFlight.getNoOfPassengers()+" Need to be 0");
secondFlight.setNoOfPassengers(200);
secondFlight.setNoOfPassengers(251);
System.out.println("The number of passangers of the second flight: " +secondFlight.getNoOfPassengers()+" Need to be 200");
//getArrival,landsEarliear tests.
System.out.println("==========================================");
System.out.println("getArrival,landsEarliear tests.");
System.out.println("==========================================");
System.out.println("The arrival time of the first flight: " +firstFlight.getArrivalTime()+" Need to be 18:55");
System.out.println("The arrival time of the second flight: " +secondFlight.getArrivalTime()+" Need to be 18:55");
System.out.println("The flight duration of the second flight: " +secondFlight.getFlightDuration()+" Need to be 400");
secondFlight.setFlightDuration(500);
System.out.println("The flight duration of the second flight: " +secondFlight.getFlightDuration()+" Need to be 500");
System.out.println("The arrival time of the first flight: " +firstFlight.getArrivalTime()+" Need to be 18:55");
System.out.println("The arrival time of the second flight: " +secondFlight.getArrivalTime() +" Need to be 20:35");
System.out.println("Is the first flight lands before the second:" +firstFlight.landsEarlier(secondFlight)+" Need to be true");
System.out.println("Is the second flight lands before the first:" +secondFlight.landsEarlier(firstFlight)+" Need to be false");
firstFlight.setFlightDuration(50000);
System.out.println("The flight duration of the first flight: " +firstFlight.getFlightDuration()+" Need to be 50000");
System.out.println("The arrival time of the first flight: " +firstFlight.getArrivalTime()+" Need to be 05:35");
System.out.println("Is the first flight lands before the second:" +firstFlight.landsEarlier(secondFlight)+" Need to be false");
System.out.println("Is the second flight lands before the first:" +secondFlight.landsEarlier(firstFlight)+" Need to be true");
//getPrice,isCheper and total price tests.
System.out.println("==========================================");
System.out.println("getPrice,isCheper and total price tests.");
System.out.println("==========================================");
System.out.println("first flight price: " +firstFlight.getPrice()+" Need to be 1000");
System.out.println("second flight price: " +secondFlight.getPrice()+" Need to be 1000");
secondFlight.setPrice(5000);
System.out.println("second flight price: " +secondFlight.getPrice()+" Need to be 5000");
System.out.println("Is the first flight cheaper than the second:" +firstFlight.isCheaper(secondFlight)+" Need to be true");
System.out.println("Is the second flight cheaper than the first:" +secondFlight.isCheaper(firstFlight)+" Need to be false");
System.out.println("The number of passangers of the first flight: " +firstFlight.getNoOfPassengers());
System.out.println("Total price of the first flight:" +firstFlight.totalPrice()+" Need to be 45000");
System.out.println("The number of passangers of the second flight: " +secondFlight.getNoOfPassengers());
System.out.println("Total price of the second flight:" +secondFlight.totalPrice()+" Need to be 1000000");
}
}