-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicket.java
More file actions
24 lines (21 loc) · 831 Bytes
/
Ticket.java
File metadata and controls
24 lines (21 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class Ticket {
// Declaring private variables to store passengerID and ticketName
private final String passengerID;
private final String ticketName;
// Constructor to initialize Ticket object with passengerID and ticketName
public Ticket(String passengerID, String ticketName ) {
this.passengerID = passengerID ;
this.ticketName = ticketName ;
}
// Getter method to retrieve the ticket name
public String getTicketName( ) {
return ticketName;
}
// Overriding the toString method to provide a string representation of the Ticket object
public String toString( ) {
return "Ticket[ " +
"PassengerID: " + passengerID + ", " +
"Ticket Name: " + ticketName + ", " +
"]";
}
}