-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTourpackage.java
156 lines (132 loc) · 5.97 KB
/
Tourpackage.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
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
package tourism;
import java.util.*;
public class Tourpackage
{
int tourid;
String tourname;
String citiesToVisit;
int noOfDays;
int priceOftourpermember;
boolean isFilled;
//all tour packages priority queues will be created
//right now only 5 customers are allowed in a tour package queue
//scope can be increase
PriorityQueue<Customer> pq = new PriorityQueue<Customer>(5, new CustomerComparator());
StringBuilder itinerary=new StringBuilder(1000);
Tourpackage()
{
this.tourid=0;
this.citiesToVisit= "";
this.noOfDays=0;
this.itinerary=null;
this.tourname="";
this.priceOftourpermember=0;
this.isFilled=false;
}
int getTourId()
{
return tourid;
}
Tourpackage(int tourid,String citiesToVisit,int noOfDays,StringBuilder itinerary,String tourname,int priceOftourpermember)
{
this.tourid=tourid;
this.citiesToVisit= citiesToVisit;
this.noOfDays=noOfDays;
this.itinerary=itinerary;
this.tourname=tourname;
this.priceOftourpermember=priceOftourpermember;
}
public void createPackage(int id)
{
String storestr[];
Scanner sc=new Scanner(System.in);
Scanner sc2=new Scanner(System.in);
Scanner sc3=new Scanner(System.in);
tourid=id;
System.out.println("Tour id of new package is assigned as "+id);
System.out.println("Enter the tour name of new package");
tourname=sc2.next();
System.out.println("Enter the price of the tour package per member");
priceOftourpermember=sc.nextInt();
System.out.println("Enter the cities to visit(Enter one after another)");
citiesToVisit=sc3.nextLine();
System.out.println("Enter the number of days of the new package");
noOfDays=sc.nextInt();
System.out.println("Enter the itinerary details");
System.out.println("Enter the number of lines you want to enter");
int l=sc.nextInt();
storestr=new String[l+1];
for(int i=0;i<l+1;i++)
{
storestr[i]=sc2.nextLine();
}
itinerary=new StringBuilder("\n*********************************************************\n\n"+tourid+")"+tourname);
for(int i=0;i<l+1;i++)
{
itinerary.append("\n"+storestr[i]);
}
}
public void displayPackage()
{ //We have to display number of customers in the priority queue
System.out.println("**************************************************");
System.out.println("\nTour name is:"+tourname);
System.out.println("\nTour id is:"+tourid);
System.out.println("\nCities to visit are:"+citiesToVisit);
System.out.println("\nNumber of days of the tour :"+noOfDays);
System.out.println("\nThe price per member is:"+priceOftourpermember);
System.out.println("\nThe itinerary is:"+itinerary);
System.out.println("**************************************************");
}
public void Discounted(int id)
{
double finalAmt=0.0;
Scanner me=new Scanner(System.in);
int chstop,tr;
int countCust=-1;
while(!pq.isEmpty())
{
countCust++;
Customer c5;
c5=pq.poll();
if(countCust==0)
{
System.out.println("**********************************************************************");
c5.displayBooking();
c5.totalamt=c5.totalamt-0.4*c5.totalamt;
System.out.println("THE CUSTOMER'S BILL IS"+c5.totalamt);
System.out.println("**********************************************************************"+"\n\n");
}
else if(countCust==1) {
System.out.println("**********************************************************************");
c5.displayBooking();
c5.totalamt=c5.totalamt-0.3*c5.totalamt;
System.out.println("THE CUSTOMER'S BILL IS"+c5.totalamt);
System.out.println("**********************************************************************"+"\n\n");
}
else if(countCust==2)
{
System.out.println("**********************************************************************");
c5.displayBooking();
c5.totalamt=c5.totalamt-0.2*c5.totalamt;
System.out.println("THE CUSTOMER'S BILL IS:"+c5.totalamt);
System.out.println("**********************************************************************"+"\n\n");
}
else if(countCust==3)
{
System.out.println("**********************************************************************");
c5.displayBooking();
c5.totalamt=c5.totalamt-0.1*c5.totalamt;
System.out.println("THE CUSTOMER'S BILL IS:"+c5.totalamt);
System.out.println("**********************************************************************"+"\n\n");
}
else if(countCust==4)
{
System.out.println("**********************************************************************");
c5.displayBooking();
c5.totalamt=c5.totalamt-0.05*c5.totalamt;
System.out.println("THE CUSTOMER'S BILL IS"+c5.totalamt);
System.out.println("**********************************************************************"+"\n\n");
}
}
}
}