-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItinerary.java
35 lines (32 loc) · 1012 Bytes
/
Itinerary.java
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
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
public class Itinerary {
private static ArrayList<Flight> plannedFlights;
private static ArrayList<Hotel> plannedHotels;
private static ArrayList<Seat> plannedSeats;
private static ArrayList<Room> plannedRooms;
public Itinerary(Account user) {
Itinerary.plannedFlights = user.getBookedFlights();
Itinerary.plannedHotels = user.getBookedHotels();
}
/**
* Prints out the itinerary to a text file
*/
public static void print() {
try {
FileWriter file = new FileWriter("itinerary.txt");
for (Flight f : plannedFlights) {
file.write(f.toString());
file.write("\n");
}
for (Hotel h : plannedHotels) {
file.write(h.toString());
}
file.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}