diff --git a/.classpath b/.classpath
index 2846539..054d362 100644
--- a/.classpath
+++ b/.classpath
@@ -8,10 +8,7 @@
-
-
-
-
-
+
+
diff --git a/build/classes/.gitignore b/build/classes/.gitignore
index 0b6c10d..7c119f6 100644
--- a/build/classes/.gitignore
+++ b/build/classes/.gitignore
@@ -1,3 +1,4 @@
-/controller/
+/testing/
/model/
/services/
+/controller/
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..e8511d9 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/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..5a228d3 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..2dfe6f3 100644
--- a/src/controller/HotelController.java
+++ b/src/controller/HotelController.java
@@ -1,6 +1,7 @@
package controller;
import java.io.IOException;
+
import java.time.LocalDate;
import javax.servlet.RequestDispatcher;
@@ -12,8 +13,8 @@
-/*import model.Hotel;
-import services.FareCalculator;*/
+import model.Hotel;
+import services.FareCalculator;
@@ -33,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 roomtype=request.getParameter("roomtype");
String occupancy=request.getParameter("occupancy");
String from=request.getParameter("from");
@@ -67,6 +68,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..1935ba3 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..4ef98ca 100644
--- a/src/model/Bus.java
+++ b/src/model/Bus.java
@@ -1,3 +1,48 @@
package model;
-// Type your code
+import java.time.LocalDate;
+
+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 String getBusType() {
+ return busType;
+ }
+ public void setBusType(String busType) {
+ this.busType = busType;
+ }
+ public int getRates() {
+ return rates;
+ }
+ public void setRates(int rates) {
+ this.rates = rates;
+ }
+ 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;
+ }
+
+
+
+
+}
diff --git a/src/model/Flight.java b/src/model/Flight.java
index 9ac54b5..d40037a 100644
--- a/src/model/Flight.java
+++ b/src/model/Flight.java
@@ -1,3 +1,62 @@
package model;
-//Type your code
\ No newline at end of file
+import java.time.LocalDate;
+
+public class Flight{
+
+ private int noOfPersons;
+ private String classType;
+ private int rates;
+ private LocalDate from;
+ private LocalDate to;
+ private String triptype;
+ public int getNoOfPersons() {
+ return noOfPersons;
+ }
+ public void setNoOfPersons(int noOfPersons) {
+ this.noOfPersons = noOfPersons;
+ }
+ public String getClassType() {
+ return classType;
+ }
+ public void setClassType(String classType) {
+ this.classType = classType;
+ }
+ public int getRates() {
+ return rates;
+ }
+ public void setRates(int rates) {
+ this.rates = rates;
+ }
+ 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;
+ }
+
+
+ public Flight(int noOfPersons, int rates, String string, LocalDate from, LocalDate to, String triptype) {
+ super();
+ this.noOfPersons = noOfPersons;
+ this.rates = rates;
+ 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..6591fef 100644
--- a/src/model/Hotel.java
+++ b/src/model/Hotel.java
@@ -1,2 +1,65 @@
package model;
-// Type your code
\ No newline at end of file
+
+import java.time.LocalDate;
+
+public class Hotel{
+ private int noOfPersons;
+ private String roomType;
+ private int rates;
+ private String occupancy;
+ private LocalDate fromdate;
+ private LocalDate todate;
+
+
+ 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;
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/src/model/Train.java b/src/model/Train.java
index b21180d..e5595b5 100644
--- a/src/model/Train.java
+++ b/src/model/Train.java
@@ -1,2 +1,49 @@
package model;
-// Type your code
\ No newline at end of file
+
+import java.time.LocalDate;
+
+public class Train{
+
+ private int noOfPersons;
+ private int rates;
+ private String berth;
+ private LocalDate date;
+
+
+ public int getNoOfPersons() {
+ return noOfPersons;
+ }
+ public void setNoOfPersons(int noOfPersons) {
+ this.noOfPersons = noOfPersons;
+ }
+ public String getBerth() {
+ return berth;
+ }
+ public void setBerth(String berth) {
+ this.berth = berth;
+ }
+ public int getRates() {
+ return rates;
+ }
+ public void setRates(int rates) {
+ this.rates = rates;
+ }
+ public LocalDate getDate() {
+ return date;
+ }
+ public void setDate(LocalDate date) {
+ this.date = date;
+ }
+
+
+ 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..69f4d1e 100644
--- a/src/services/Booking.java
+++ b/src/services/Booking.java
@@ -1,4 +1,12 @@
package services;
-// Type your code
+public class Booking{
+ double totalFare;
+
+ public double booking(int noOfPersons,int rates) {
+
+ totalFare = noOfPersons * rates;
+ return totalFare;
+ }
+}
diff --git a/src/services/FareCalculator.java b/src/services/FareCalculator.java
index 6d38ab5..725fba1 100644
--- a/src/services/FareCalculator.java
+++ b/src/services/FareCalculator.java
@@ -1,3 +1,65 @@
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;
+
+public class FareCalculator extends Booking{
+
+ @Override
+ public double booking(int noOfPersons, int rates) {
+ // TODO Auto-generated method stub
+ return super.booking(noOfPersons, rates);
+ }
+
+ public double book(Hotel hotel) {
+
+ LocalDate checkInDate = hotel.getFromdate();
+ LocalDate checkOutDate = hotel.getTodate();
+
+ if(hotel.getNoOfPersons() == 1) {
+ hotel.setOccupancy("Single");
+ }
+ else if(hotel.getNoOfPersons() == 2) {
+ hotel.setOccupancy("Double");
+ }
+
+ else if(hotel.getNoOfPersons()%2 == 0 && hotel.getNoOfPersons() > 2) {
+ int o = hotel.getNoOfPersons()/2;
+ hotel.setOccupancy("%d Double");
+ }
+
+ if(checkInDate.isBefore(checkOutDate)) {
+ totalFare = hotel.getNoOfPersons()*hotel.getRates();
+ }
+ return totalFare;
+
+
+ }
+
+ public double book(Flight flight) {
+
+ totalFare = flight.getNoOfPersons()*flight.getRates();
+ return totalFare;
+ }
+
+ public double book(Train train) {
+ totalFare = train.getNoOfPersons()*train.getRates();
+ return totalFare;
+
+
+ }
+
+ public double book(Bus bus) {
+
+ totalFare = bus.getNoOfPersons()*bus.getRates();
+ return totalFare;
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/testing/TestBooking.java b/src/testing/TestBooking.java
index a729b9b..cc436b8 100644
--- a/src/testing/TestBooking.java
+++ b/src/testing/TestBooking.java
@@ -1,6 +1,5 @@
package testing;
-/* Uncomment the below code to test your application
import static org.junit.Assert.*;
import org.junit.Test;
@@ -23,4 +22,4 @@ public void testBookingMethod() {
}
}
}
-*/
+
diff --git a/src/testing/TestBus.java b/src/testing/TestBus.java
index 90df968..b7e6693 100644
--- a/src/testing/TestBus.java
+++ b/src/testing/TestBus.java
@@ -1,6 +1,5 @@
package testing;
-/* Uncomment the below code to test your application
import model.Bus;
import java.time.LocalDate;
@@ -57,7 +56,6 @@ public void testSetDate() {
} catch (Exception e) {
e.printStackTrace();
}
- }
+}
}
-*/
diff --git a/src/testing/TestFareCalculator.java b/src/testing/TestFareCalculator.java
index 91dddec..f68768e 100644
--- a/src/testing/TestFareCalculator.java
+++ b/src/testing/TestFareCalculator.java
@@ -1,6 +1,5 @@
package testing;
-/* Uncomment the below code to test your application
import static org.junit.Assert.*;
@@ -89,4 +88,4 @@ public void testTrainMethod() {
}
}
}
-*/
+
diff --git a/src/testing/TestFlight.java b/src/testing/TestFlight.java
index 90127f6..814b8e3 100644
--- a/src/testing/TestFlight.java
+++ b/src/testing/TestFlight.java
@@ -1,6 +1,5 @@
package testing;
-/* Uncomment the below code to test your application
import model.Flight;
import java.time.LocalDate;
@@ -62,4 +61,4 @@ public void testSetDate() {
}
}
-*/
+
diff --git a/src/testing/TestHotel.java b/src/testing/TestHotel.java
index 2d3565b..f90b4c2 100644
--- a/src/testing/TestHotel.java
+++ b/src/testing/TestHotel.java
@@ -1,6 +1,5 @@
package testing;
-/* Uncomment the below code to test your application
import model.Hotel;
import java.time.LocalDate;
@@ -62,4 +61,4 @@ public void testSetDate() {
}
}
-*/
+
diff --git a/src/testing/TestRunner.java b/src/testing/TestRunner.java
index f26d18d..733173b 100644
--- a/src/testing/TestRunner.java
+++ b/src/testing/TestRunner.java
@@ -1,11 +1,12 @@
package testing;
-/* Uncomment the below code to test your application
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
+import junit.framework.TestSuite;
+
public class TestRunner {
public static void main(String[] args) {
Result result = JUnitCore.runClasses(TestSuite.class);
@@ -17,4 +18,3 @@ public static void main(String[] args) {
System.out.println(result.wasSuccessful());
}
}
-*/
diff --git a/src/testing/TestSuite.java b/src/testing/TestSuite.java
index a48a79e..de6ceae 100644
--- a/src/testing/TestSuite.java
+++ b/src/testing/TestSuite.java
@@ -1,15 +1,15 @@
package testing;
-/* Uncomment the below code to test your application
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
+
@RunWith(Suite.class)
@SuiteClasses({ TestBooking.class, TestBus.class, TestFareCalculator.class, TestFlight.class, TestHotel.class,
TestTrain.class })
public class TestSuite {
}
-*/
+
diff --git a/src/testing/TestTrain.java b/src/testing/TestTrain.java
index 688df5c..8c9b8ce 100644
--- a/src/testing/TestTrain.java
+++ b/src/testing/TestTrain.java
@@ -1,6 +1,5 @@
package testing;
-/* Uncomment the below code to test your application
import model.Train;
import java.time.LocalDate;
@@ -64,4 +63,3 @@ public void testSetDate() {
}
}
-*/