Repository navigation
Expand file tree
/
Copy pathBooking.java
More file actions
38 lines (34 loc) · 1.84 KB
/
Copy pathBooking.java
File metadata and controls
38 lines (34 loc) · 1.84 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
public class Booking {
private static int counter = 1000;
private String bookingId;
private String flightNumber;
private String passengerName;
private String passengerEmail;
private int seats;
private double totalPrice;
public Booking(String flightNumber, String passengerName, String passengerEmail, int seats, double pricePerSeat) {
this.bookingId = "BK" + (++counter);
this.flightNumber = flightNumber;
this.passengerName = passengerName;
this.passengerEmail = passengerEmail;
this.seats = seats;
this.totalPrice = seats * pricePerSeat;
}
public String getBookingId() { return bookingId; }
public String getFlightNumber() { return flightNumber; }
public String getPassengerName() { return passengerName; }
public int getSeats() { return seats; }
public double getTotalPrice() { return totalPrice; }
public void display() {
System.out.println("╔══════════════════════════════════════╗");
System.out.println(" 🎫 BOOKING CONFIRMED");
System.out.println("╚══════════════════════════════════════╝");
System.out.println(" Booking ID : " + bookingId);
System.out.println(" Flight : " + flightNumber);
System.out.println(" Passenger : " + passengerName);
System.out.println(" Email : " + passengerEmail);
System.out.println(" Seats Booked : " + seats);
System.out.printf (" Total Price : $%.2f%n", totalPrice);
System.out.println("════════════════════════════════════════");
}
}