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..600bb33 100644 --- a/build/classes/.gitignore +++ b/build/classes/.gitignore @@ -1,3 +1,4 @@ -/controller/ /model/ /services/ +/controller/ +/testing/ diff --git a/build/classes/controller/BusController.class b/build/classes/controller/BusController.class index 59d8dfc..8971f0a 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..95e6f97 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..94a0f16 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..c2d2956 100644 --- a/src/controller/BusController.java +++ b/src/controller/BusController.java @@ -9,6 +9,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import model.*; +import services.*; @WebServlet(urlPatterns= {"/bus"}) public class BusController extends HttpServlet { @@ -28,7 +30,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 +74,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..2f8e8f4 100644 --- a/src/controller/FlightController.java +++ b/src/controller/FlightController.java @@ -9,8 +9,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - - +import model.*; +import services.*; @WebServlet("/flight") public class FlightController extends HttpServlet { @@ -29,7 +29,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 +59,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..a9a5df0 100644 --- a/src/controller/HotelController.java +++ b/src/controller/HotelController.java @@ -10,7 +10,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - +import model.*; +import services.*; /*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..50ed9be 100644 --- a/src/controller/TrainController.java +++ b/src/controller/TrainController.java @@ -9,7 +9,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - +import model.*; +import services.*; /** * Servlet implementation class TrainController @@ -31,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 berth=request.getParameter("berth"); String date=request.getParameter("to"); System.out.println(numberOfPersons); @@ -68,6 +69,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..ef8ba42 100644 --- a/src/model/Bus.java +++ b/src/model/Bus.java @@ -1,3 +1,52 @@ package model; // Type your code +import java.time.LocalDate; + +public class Bus{ + private int noOfPersons; + private String busType; + private int rates; + private LocalDate date; + + public Bus(int noOfPersons, int rates, String busType, LocalDate date){ + this.noOfPersons = noOfPersons; + this.rates = rates; + this.busType = busType; + this.date = 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; + } + + +} \ No newline at end of file diff --git a/src/model/Flight.java b/src/model/Flight.java index 9ac54b5..4652667 100644 --- a/src/model/Flight.java +++ b/src/model/Flight.java @@ -1,3 +1,73 @@ package model; +import java.time.LocalDate; -//Type your code \ No newline at end of file +//Type your code + +public class Flight{ + + private int noOfPersons; + private String classType; + private int rates; + private LocalDate from; + private LocalDate to; + private String triptype; + + public Flight(int noOfPersons,int rates,String classType, LocalDate from,LocalDate to,String triptype) { + this.noOfPersons = noOfPersons; + this.rates = rates; + this.from = from; + this.to = to; + this.triptype = triptype; + this.classType = classType; + } + + 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; + } + + +} \ No newline at end of file diff --git a/src/model/Hotel.java b/src/model/Hotel.java index b21180d..31b38ae 100644 --- a/src/model/Hotel.java +++ b/src/model/Hotel.java @@ -1,2 +1,72 @@ package model; -// Type your code \ No newline at end of file +// Type your code +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 Hotel(int noOfPersons, String roomType, int rates,String occupancy,LocalDate fromdate,LocalDate todate) { + this.noOfPersons = noOfPersons; + this.roomType = roomType; + this.rates = rates; + this.occupancy = occupancy; + this.fromdate = fromdate; + this.todate = 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; + } + + + +} diff --git a/src/model/Train.java b/src/model/Train.java index b21180d..5c2d340 100644 --- a/src/model/Train.java +++ b/src/model/Train.java @@ -1,2 +1,51 @@ package model; -// Type your code \ No newline at end of file +// Type your code +import java.time.LocalDate; + +public class Train{ + private int noOfPersons; + private String berth; + private int rates; + private LocalDate date; + + public Train(int noOfPersons, int rates, String berth, LocalDate date) { + this.noOfPersons = noOfPersons; + this.rates = rates; + this.berth = berth; + this.date = 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; + } + + +} \ No newline at end of file diff --git a/src/services/Booking.java b/src/services/Booking.java index fe2c822..ffd1e32 100644 --- a/src/services/Booking.java +++ b/src/services/Booking.java @@ -2,3 +2,10 @@ // Type your code +public class Booking{ + + public double booking(int noOfPersons,int rates) { + + return (double)noOfPersons*rates; + } +} \ No newline at end of file diff --git a/src/services/FareCalculator.java b/src/services/FareCalculator.java index 6d38ab5..af35ea5 100644 --- a/src/services/FareCalculator.java +++ b/src/services/FareCalculator.java @@ -1,3 +1,31 @@ package services; -// Type your code \ No newline at end of file +// Type your code +import model.*; + + +public class FareCalculator extends Booking{ + + public double book(Hotel hotel) { + if(hotel.getTodate().isAfter(hotel.getFromdate())) + return booking(hotel.getNoOfPersons(), hotel.getRates()); + return 0; + } + + public double book(Flight flight) { + + if(flight.getTriptype().contentEquals("one-way")) + return booking(flight.getNoOfPersons(), flight.getRates()); + else if(flight.getTriptype().contentEquals("round trip")) + return booking(flight.getNoOfPersons(), flight.getRates())*2; + return 0; + } + + public double book(Train train) { + return booking(train.getNoOfPersons(), train.getRates()); + } + + public double book(Bus bus) { + return booking(bus.getNoOfPersons(), bus.getRates()); + } +} \ No newline at end of file diff --git a/src/testing/TestBooking.java b/src/testing/TestBooking.java index a729b9b..c674be0 100644 --- a/src/testing/TestBooking.java +++ b/src/testing/TestBooking.java @@ -1,6 +1,6 @@ package testing; -/* Uncomment the below code to test your application +/* Uncomment the below code to test your application*/ import static org.junit.Assert.*; import org.junit.Test; @@ -23,4 +23,4 @@ public void testBookingMethod() { } } } -*/ + diff --git a/src/testing/TestBus.java b/src/testing/TestBus.java index 90df968..11c514b 100644 --- a/src/testing/TestBus.java +++ b/src/testing/TestBus.java @@ -1,6 +1,6 @@ package testing; -/* Uncomment the below code to test your application +/* Uncomment the below code to test your application*/ import model.Bus; import java.time.LocalDate; @@ -60,4 +60,4 @@ public void testSetDate() { } } -*/ + diff --git a/src/testing/TestFareCalculator.java b/src/testing/TestFareCalculator.java index 91dddec..1f50e31 100644 --- a/src/testing/TestFareCalculator.java +++ b/src/testing/TestFareCalculator.java @@ -1,6 +1,6 @@ package testing; -/* Uncomment the below code to test your application +/* Uncomment the below code to test your application */ import static org.junit.Assert.*; @@ -89,4 +89,4 @@ public void testTrainMethod() { } } } -*/ + diff --git a/src/testing/TestFlight.java b/src/testing/TestFlight.java index 90127f6..71a92de 100644 --- a/src/testing/TestFlight.java +++ b/src/testing/TestFlight.java @@ -1,6 +1,6 @@ package testing; -/* Uncomment the below code to test your application +/* Uncomment the below code to test your application */ import model.Flight; import java.time.LocalDate; @@ -62,4 +62,4 @@ public void testSetDate() { } } -*/ + diff --git a/src/testing/TestHotel.java b/src/testing/TestHotel.java index 2d3565b..32266ae 100644 --- a/src/testing/TestHotel.java +++ b/src/testing/TestHotel.java @@ -1,6 +1,6 @@ package testing; -/* Uncomment the below code to test your application +/* Uncomment the below code to test your application*/ import model.Hotel; import java.time.LocalDate; @@ -62,4 +62,4 @@ public void testSetDate() { } } -*/ + diff --git a/src/testing/TestRunner.java b/src/testing/TestRunner.java index f26d18d..73f13fe 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 +/* Uncomment the below code to test your application */ import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.notification.Failure; + public class TestRunner { public static void main(String[] args) { Result result = JUnitCore.runClasses(TestSuite.class); @@ -17,4 +18,4 @@ 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..8427811 100644 --- a/src/testing/TestSuite.java +++ b/src/testing/TestSuite.java @@ -1,15 +1,14 @@ package testing; -/* Uncomment the below code to test your application +/* 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 }) +@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..91e5791 100644 --- a/src/testing/TestTrain.java +++ b/src/testing/TestTrain.java @@ -1,6 +1,6 @@ package testing; -/* Uncomment the below code to test your application +/* Uncomment the below code to test your application*/ import model.Train; import java.time.LocalDate; @@ -64,4 +64,4 @@ public void testSetDate() { } } -*/ +