-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTicketReservation
More file actions
99 lines (75 loc) · 2.24 KB
/
TicketReservation
File metadata and controls
99 lines (75 loc) · 2.24 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
import java.util.Scanner;
@FunctionalInterface
interface Booking{
public void book();
}
class Ticket{
long ticketNo;
String traverllerName;
String dateOfBooking;
double price;
public Ticket() {
}
public Ticket(long ticketNo, String traverllerName, String dateOfBooking, double price) {
this.ticketNo=ticketNo;
this.traverllerName = traverllerName;
this.dateOfBooking = dateOfBooking;
this.price = price;
}
public long getTicketNo() {
return ticketNo;
}
public void setTicketNo(long ticketNo) {
this.ticketNo = ticketNo;
}
public String getTraverllerName() {
return traverllerName;
}
public void setTraverllerName(String traverllerName) {
this.traverllerName = traverllerName;
}
public String getDateOfBooking() {
return dateOfBooking;
}
public void setDateOfBooking(String dateOfBooking) {
this.dateOfBooking = dateOfBooking;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
@Override
public String toString() {
return "Ticket Details are : {" +
"ticketNo=" + ticketNo +
", traverllerName='" + traverllerName + '\'' +
", dateOfBooking='" + dateOfBooking + '\'' +
", price=" + price +
'}';
}
public Ticket BookTicket(){
Scanner sc;String tname;String dob;
double price=459.56;
System.out.println("Enter if you want to travel?");
int choice =new Scanner(System.in).nextInt();
if (choice==1) {
System.out.println("Enter your name");
sc = new Scanner(System.in);
tname = sc.next();
System.out.println("Enter date of travel in 2-03-2024 format");
dob = sc.next();
Ticket firstTicket = new Ticket(ticketNo, tname, dob, price);
return firstTicket;
}
return new Ticket() ;
}
}
public class TicketReservation {
public static void main(String[] args) {
System.out.println("Ticket Zone;");
Ticket t1=new Ticket();
System.out.println(t1.BookTicket());
}
}