diff --git a/.classpath b/.classpath
index 2846539..20c137d 100644
--- a/.classpath
+++ b/.classpath
@@ -8,10 +8,6 @@
-
-
-
-
-
+
diff --git a/build/classes/.gitignore b/build/classes/.gitignore
deleted file mode 100644
index 0b6c10d..0000000
--- a/build/classes/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/controller/
-/model/
-/services/
diff --git a/build/classes/controller/BusController.class b/build/classes/controller/BusController.class
index 59d8dfc..82c8302 100644
Binary files a/build/classes/controller/BusController.class and b/build/classes/controller/BusController.class differ
diff --git a/build/classes/controller/FlightController.class b/build/classes/controller/FlightController.class
index 4023961..ea3fef4 100644
Binary files a/build/classes/controller/FlightController.class and b/build/classes/controller/FlightController.class differ
diff --git a/build/classes/controller/HotelController.class b/build/classes/controller/HotelController.class
index 9738d37..be4ceee 100644
Binary files a/build/classes/controller/HotelController.class and b/build/classes/controller/HotelController.class differ
diff --git a/build/classes/controller/TrainController.class b/build/classes/controller/TrainController.class
index 167c495..72c2986 100644
Binary files a/build/classes/controller/TrainController.class and b/build/classes/controller/TrainController.class differ
diff --git a/build/classes/model/Bus.class b/build/classes/model/Bus.class
new file mode 100644
index 0000000..4671d54
Binary files /dev/null and b/build/classes/model/Bus.class differ
diff --git a/build/classes/model/Flight.class b/build/classes/model/Flight.class
new file mode 100644
index 0000000..0f8a320
Binary files /dev/null and b/build/classes/model/Flight.class differ
diff --git a/build/classes/model/Hotel.class b/build/classes/model/Hotel.class
new file mode 100644
index 0000000..6a3b5ef
Binary files /dev/null and b/build/classes/model/Hotel.class differ
diff --git a/build/classes/model/Train.class b/build/classes/model/Train.class
new file mode 100644
index 0000000..1a9ac7d
Binary files /dev/null and b/build/classes/model/Train.class differ
diff --git a/build/classes/services/Booking.class b/build/classes/services/Booking.class
new file mode 100644
index 0000000..399892d
Binary files /dev/null and b/build/classes/services/Booking.class differ
diff --git a/build/classes/services/FareCalculator.class b/build/classes/services/FareCalculator.class
new file mode 100644
index 0000000..f7597c9
Binary files /dev/null and b/build/classes/services/FareCalculator.class differ
diff --git a/src/controller/BusController.java b/src/controller/BusController.java
index f1f8372..2e78db4 100644
--- a/src/controller/BusController.java
+++ b/src/controller/BusController.java
@@ -10,6 +10,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import model.Bus;
+import services.FareCalculator;
+
@WebServlet(urlPatterns= {"/bus"})
public class BusController extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -28,7 +31,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-/*
+
int numberOfPersons=Integer.parseInt(request.getParameter("persons"));
String bustype=request.getParameter("bustype");
@@ -72,6 +75,6 @@ else if(bustype.equals("nonacsemisleeper")) {
request.setAttribute("busfare", rate);
RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/views/busView.jsp");
dispatcher.forward(request, response);
-*/ }
+ }
}
diff --git a/src/controller/FlightController.java b/src/controller/FlightController.java
index 7760e3c..645d836 100644
--- a/src/controller/FlightController.java
+++ b/src/controller/FlightController.java
@@ -10,6 +10,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import model.Flight;
+import services.FareCalculator;
+
@WebServlet("/flight")
@@ -29,7 +32,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-/* int numberOfPersons=Integer.parseInt(request.getParameter("persons"));
+ int numberOfPersons=Integer.parseInt(request.getParameter("persons"));
String classtype=request.getParameter("class");
String from=request.getParameter("from");
String to=request.getParameter("to");
@@ -59,6 +62,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
request.setAttribute("flightfare", rate);
RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/views/flightView.jsp");
dispatcher.forward(request, response);
- */}
+ }
}
diff --git a/src/controller/HotelController.java b/src/controller/HotelController.java
index 0c39e3b..d6f2abc 100644
--- a/src/controller/HotelController.java
+++ b/src/controller/HotelController.java
@@ -12,8 +12,8 @@
-/*import model.Hotel;
-import services.FareCalculator;*/
+import model.Hotel;
+import services.FareCalculator;
@@ -33,7 +33,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-/* int numberOfPersons=Integer.parseInt(request.getParameter("persons"));
+ int numberOfPersons=Integer.parseInt(request.getParameter("persons"));
String roomtype=request.getParameter("roomtype");
String occupancy=request.getParameter("occupancy");
String from=request.getParameter("from");
@@ -67,6 +67,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/views/hotelOutputView.jsp");
dispatcher.forward(request, response);
-*/ }
+ }
}
diff --git a/src/controller/TrainController.java b/src/controller/TrainController.java
index dcc07df..3764d7e 100644
--- a/src/controller/TrainController.java
+++ b/src/controller/TrainController.java
@@ -10,6 +10,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import model.Train;
+import services.FareCalculator;
+
/**
* Servlet implementation class TrainController
@@ -31,7 +34,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-/* int numberOfPersons=Integer.parseInt(request.getParameter("persons"));
+ int numberOfPersons=Integer.parseInt(request.getParameter("persons"));
String berth=request.getParameter("berth");
String date=request.getParameter("to");
System.out.println(numberOfPersons);
@@ -68,6 +71,6 @@ else if(berth.equals("nonac")) {
request.setAttribute("trainfare", trainfare);
RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/views/trainView.jsp");
dispatcher.forward(request, response);
- */}
+ }
}
diff --git a/src/model/Bus.java b/src/model/Bus.java
index 430ca5d..d869866 100644
--- a/src/model/Bus.java
+++ b/src/model/Bus.java
@@ -1,3 +1,45 @@
package model;
+import java.time.LocalDate;
+
// Type your code
+//parent class called Bus
+public class Bus{
+ private int noOfPersons;
+ private int rates;
+ private String busType;
+ private LocalDate date;
+ public int getNoOfPersons() {
+ return noOfPersons;
+ }
+ public void setNoOfPersons(int noOfPersons) {
+ this.noOfPersons = noOfPersons;
+ }
+ public int getRates() {
+ return rates;
+ }
+ public void setRates(int rates) {
+ this.rates = rates;
+ }
+ public String getBusType() {
+ return busType;
+ }
+ public void setBusType(String busType) {
+ this.busType = busType;
+ }
+ public LocalDate getDate() {
+ return date;
+ }
+ public void setDate(LocalDate date) {
+ this.date = date;
+ }
+ public Bus(int noOfPersons, int rates, String busType, LocalDate date) {
+ super();
+ this.noOfPersons = noOfPersons;
+ this.rates = rates;
+ this.busType = busType;
+ this.date = date;
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/model/Flight.java b/src/model/Flight.java
index 9ac54b5..1a99186 100644
--- a/src/model/Flight.java
+++ b/src/model/Flight.java
@@ -1,3 +1,63 @@
package model;
-//Type your code
\ No newline at end of file
+import java.time.LocalDate;
+
+//Type your code
+//parent class called Flight
+public class Flight{
+ private int noOfPersons;
+ private int rates;
+ private String classType;
+ private LocalDate from;
+ private LocalDate to;
+ private String triptype;
+ //appropriate getters and setters
+ public int getNoOfPersons() {
+ return noOfPersons;
+ }
+ public void setNoOfPersons(int noOfPersons) {
+ this.noOfPersons = noOfPersons;
+ }
+ public int getRates() {
+ return rates;
+ }
+ public void setRates(int rates) {
+ this.rates = rates;
+ }
+ public String getClassType() {
+ return classType;
+ }
+ public void setClassType(String classType) {
+ this.classType = classType;
+ }
+ public LocalDate getFrom() {
+ return from;
+ }
+ public void setFrom(LocalDate from) {
+ this.from = from;
+ }
+ public LocalDate getTo() {
+ return to;
+ }
+ public void setTo(LocalDate to) {
+ this.to = to;
+ }
+ public String getTriptype() {
+ return triptype;
+ }
+ public void setTriptype(String triptype) {
+ this.triptype = triptype;
+ }
+ //constructor
+ public Flight(int noOfPersons, int rates, String classType, LocalDate from, LocalDate to, String triptype) {
+ super();
+ this.noOfPersons = noOfPersons;
+ this.rates = rates;
+ this.classType = classType;
+ this.from = from;
+ this.to = to;
+ this.triptype = triptype;
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/model/Hotel.java b/src/model/Hotel.java
index b21180d..4ed1d4a 100644
--- a/src/model/Hotel.java
+++ b/src/model/Hotel.java
@@ -1,2 +1,66 @@
package model;
-// Type your code
\ No newline at end of file
+
+import java.time.LocalDate;
+
+// Type your code
+
+public class Hotel{
+ //parent class called Hotel
+ private int noOfPersons;
+ private String roomType;
+ private int rates;
+ private String occupancy;
+ private LocalDate fromdate;
+ private LocalDate todate;
+ //appropriate getters and setters
+ public int getNoOfPersons() {
+ return noOfPersons;
+ }
+ public void setNoOfPersons(int noOfPersons) {
+ this.noOfPersons = noOfPersons;
+ }
+ public String getRoomType() {
+ return roomType;
+ }
+ public void setRoomType(String roomType) {
+ this.roomType = roomType;
+ }
+ public int getRates() {
+ return rates;
+ }
+ public void setRates(int rates) {
+ this.rates = rates;
+ }
+ public String getOccupancy() {
+ return occupancy;
+ }
+ public void setOccupancy(String occupancy) {
+ this.occupancy = occupancy;
+ }
+ public LocalDate getFromdate() {
+ return fromdate;
+ }
+ public void setFromdate(LocalDate fromdate) {
+ this.fromdate = fromdate;
+ }
+ public LocalDate getTodate() {
+ return todate;
+ }
+ public void setTodate(LocalDate todate) {
+ this.todate = todate;
+ }
+ public Hotel(int noOfPersons, String roomType, int rates, String occupancy, LocalDate fromdate, LocalDate todate) {
+ super();
+ this.noOfPersons = noOfPersons;
+ this.roomType = roomType;
+ this.rates = rates;
+ this.occupancy = occupancy;
+ this.fromdate = fromdate;
+ this.todate = todate;
+ }
+
+ //constructor
+
+
+
+}
\ No newline at end of file
diff --git a/src/model/Train.java b/src/model/Train.java
index b21180d..fca0c64 100644
--- a/src/model/Train.java
+++ b/src/model/Train.java
@@ -1,2 +1,46 @@
package model;
-// Type your code
\ No newline at end of file
+// Type your code
+
+import java.time.LocalDate;
+
+//parent class called Train
+public class Train{
+ private int noOfPersons;
+ private int rates;
+ private String berth;
+ private LocalDate date;
+ //appropriate getters and setters
+ public int getNoOfPersons() {
+ return noOfPersons;
+ }
+ public void setNoOfPersons(int noOfPersons) {
+ this.noOfPersons = noOfPersons;
+ }
+ public int getRates() {
+ return rates;
+ }
+ public void setRates(int rates) {
+ this.rates = rates;
+ }
+ public String getBerth() {
+ return berth;
+ }
+ public void setBerth(String berth) {
+ this.berth = berth;
+ }
+ public LocalDate getDate() {
+ return date;
+ }
+ public void setDate(LocalDate date) {
+ this.date = date;
+ }
+ //constructor
+ public Train(int noOfPersons, int rates, String berth, LocalDate date) {
+ super();
+ this.noOfPersons = noOfPersons;
+ this.rates = rates;
+ this.berth = berth;
+ this.date = date;
+ }
+
+}
\ No newline at end of file
diff --git a/src/services/Booking.java b/src/services/Booking.java
index fe2c822..3c914fd 100644
--- a/src/services/Booking.java
+++ b/src/services/Booking.java
@@ -1,4 +1,11 @@
package services;
// Type your code
-
+//class called as Booking
+public class Booking{
+ //method public double booking(int noOfPersons,int rates).
+ public double booking(int noOfPersons,int rates) {
+ double totalRate =noOfPersons*rates;
+ return totalRate;
+ }
+}
diff --git a/src/services/FareCalculator.java b/src/services/FareCalculator.java
index 6d38ab5..35e757a 100644
--- a/src/services/FareCalculator.java
+++ b/src/services/FareCalculator.java
@@ -1,3 +1,91 @@
package services;
-// Type your code
\ No newline at end of file
+import java.time.LocalDate;
+
+import model.Bus;
+import model.Flight;
+import model.Hotel;
+import model.Train;
+import services.Booking;
+
+// Type your code
+public class FareCalculator extends Booking{
+ Booking book = new Booking(); //obj of booking
+ //methods
+ public double book(Hotel hotel) {
+ int noOfPersons = hotel.getNoOfPersons();
+ String roomType = hotel.getRoomType();
+ int rates = hotel.getRates();
+ String occupancy = hotel.getOccupancy();
+ LocalDate fromdate = hotel.getFromdate();
+ LocalDate todate = hotel.getTodate();
+ double totalFare = 0;
+ //Check-In date should be less than Check-Out date
+ //Single occupancy can be given only for 1 guest
+ //If there are 3 guests then the rooms alloted should be 1 Double Occupancy room and 1 Single Occupancy
+ if(fromdate.isBefore(todate)) {
+ System.out.println(occupancy);
+ if((occupancy.equals("single") && noOfPersons == 1)) {
+ totalFare= book.booking(noOfPersons, rates);
+ System.out.println("totalFare: "+totalFare);
+ }
+ else if((occupancy.equals("double") )) {
+ if(noOfPersons <=2 && noOfPersons>0) {
+ totalFare= book.booking(noOfPersons, rates);
+ }
+ }
+ }
+
+ return totalFare;
+
+ }
+ public double book(Flight flight) {
+ int noOfPersons = flight.getNoOfPersons();
+ int rates = flight.getRates();
+ String classType = flight.getClassType();
+ LocalDate from = flight.getFrom();
+ LocalDate to = flight.getTo();
+ String triptype =flight.getTriptype();
+ double totalFare = 0;
+ //If one way trip is selected then departure date is not considered for fare calculation.*
+ //For round trips Start date should be less than return date.*
+ System.out.println(triptype);
+ if(triptype.equals("round-trip")) {
+ if((from.isBefore(to))){
+ totalFare= book.booking(noOfPersons, rates);
+ }
+
+ }
+ else
+ totalFare= book.booking(noOfPersons, rates);
+
+ return totalFare;
+
+ }
+ public double book(Train train) {
+ int noOfPersons = train.getNoOfPersons();
+ int rates= train.getRates();
+ String berth = train.getBerth();
+ LocalDate date = train.getDate();
+ double totalFare = 0;
+
+ totalFare= book.booking(noOfPersons, rates);
+
+ return totalFare;
+
+ }
+ public double book(Bus bus) {
+ double totalFare = 0;
+ int noOfPersons = bus.getNoOfPersons();
+ int rates= bus.getRates();
+ String busType = bus.getBusType();
+ LocalDate date = bus.getDate();
+
+ totalFare= book.booking(noOfPersons, rates);
+
+ return totalFare;
+ }
+
+
+
+}
\ No newline at end of file