diff --git a/build/classes/.gitignore b/build/classes/.gitignore index 0b6c10d..aa6d612 100644 --- a/build/classes/.gitignore +++ b/build/classes/.gitignore @@ -1,3 +1,4 @@ /controller/ /model/ /services/ +/testing/ diff --git a/build/classes/controller/BusController.class b/build/classes/controller/BusController.class index 59d8dfc..767d632 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..6d9d7b5 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..78f7498 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..a9aee35 100644 --- a/src/controller/BusController.java +++ b/src/controller/BusController.java @@ -28,7 +28,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 +72,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..f401ca9 100644 --- a/src/controller/FlightController.java +++ b/src/controller/FlightController.java @@ -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..14e58ec 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..f0d07c1 100644 --- a/src/controller/TrainController.java +++ b/src/controller/TrainController.java @@ -11,9 +11,9 @@ import javax.servlet.http.HttpServletResponse; -/** - * Servlet implementation class TrainController - */ + + Servlet implementation class TrainController + @WebServlet("/train") public class TrainController extends HttpServlet { private static final long serialVersionUID = 1L; @@ -31,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")); + int numberOfPersons=Integer.parseInt(request.getParameter("persons")); String berth=request.getParameter("berth"); String date=request.getParameter("to"); System.out.println(numberOfPersons); @@ -68,6 +68,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..248af42 100644 --- a/src/model/Bus.java +++ b/src/model/Bus.java @@ -1,3 +1,52 @@ package model; +import java.time.LocalDate; + // Type your code + +//class bus +public class Bus{ + + //instance variables/arguments + private int noOfPersons; + private String busType; + private int rates; + private LocalDate date; + + + //getter and setter + 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; + } + + //constructor + public Bus(int noOfPersons, int rates, String busType, LocalDate date) { + super(); + this.noOfPersons = noOfPersons; + this.busType = busType; + this.rates = rates; + this.date = date; + } + +} \ No newline at end of file diff --git a/src/model/Flight.java b/src/model/Flight.java index 9ac54b5..7570702 100644 --- a/src/model/Flight.java +++ b/src/model/Flight.java @@ -1,3 +1,67 @@ package model; -//Type your code \ No newline at end of file +import java.time.LocalDate; + +//Type your code + +//class flight +public class Flight{ + + //instance variables/arguments + private int noOfPersons; + private String classType; + private int rates; + private LocalDate from; + private LocalDate to; + private String triptype; + + //getter and setter + 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; + } + + //constructor + public Flight(int noOfPersons, int rates, String classType, LocalDate from, LocalDate to, String triptype) { + super(); + this.noOfPersons = noOfPersons; + this.classType = classType; + 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..6b19704 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; + +// Type your code + +//class hotel +public class Hotel{ + private int noOfPersons; + private String roomType; + private int rates; + private String occupancy; + private LocalDate fromdate; + private LocalDate todate; + + //getter and setter + 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; + } + + //constructor + 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..6b19704 100644 --- a/src/model/Train.java +++ b/src/model/Train.java @@ -1,2 +1,65 @@ package model; -// Type your code \ No newline at end of file + +import java.time.LocalDate; + +// Type your code + +//class hotel +public class Hotel{ + private int noOfPersons; + private String roomType; + private int rates; + private String occupancy; + private LocalDate fromdate; + private LocalDate todate; + + //getter and setter + 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; + } + + //constructor + 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/services/Booking.java b/src/services/Booking.java index fe2c822..94d4c77 100644 --- a/src/services/Booking.java +++ b/src/services/Booking.java @@ -2,3 +2,17 @@ // Type your code +//parent class +public class Booking{ + + //method returning rates + public double booking(int noOfPersons,int rates) + { + + double d=(double)noOfPersons*rates; + return d; + +} + + +} \ No newline at end of file diff --git a/src/services/FareCalculator.java b/src/services/FareCalculator.java index 6d38ab5..94e90a3 100644 --- a/src/services/FareCalculator.java +++ b/src/services/FareCalculator.java @@ -1,3 +1,92 @@ 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; + +// Type your code + + +//child class inhereted from parent +public class FareCalculator extends Booking +{ + Booking b=new Booking(); + + //method hotel + 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 d=0; + if(todate.isAfter(fromdate)) + { + Double data1; + + data1 = b.booking(noOfPersons, rates); + return data1; + } + else + return d; + + } + + + //method flight + public double book(Flight flight) { + int noOfPersons=flight.getNoOfPersons(); + String classType=flight.getClassType(); + int rates=flight.getRates(); + LocalDate from=flight.getFrom(); + LocalDate to=flight.getTo(); + String triptype=flight.getTriptype(); + + double data=0; + + //condition check + if(triptype=="One-way") + { + data =b.booking(noOfPersons, rates); + } + else + { + if(to.isAfter(from)) + data=b.booking(noOfPersons, rates); + } + + return data ; + + } + + //method train + public double book(Train train) + { + int noOfPersons=train.getNoOfPersons(); + String berth=train.getBerth(); + int rates=train.getRates(); + LocalDate date=train.getDate(); + double data =b.booking(noOfPersons, rates); + + return data ; + + } + + //method bus + public double book(Bus bus) + { + int noOfPersons=bus.getNoOfPersons(); + String busType=bus.getBusType(); + int rates=bus.getRates(); + LocalDate date=bus.getDate(); + double data =b.booking(noOfPersons, rates); + + return data ; + } + + } diff --git a/src/testing/TestBooking.java b/src/testing/TestBooking.java index a729b9b..ff65976 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 + 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..f144daf 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 + 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 32cb953..91adab2 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..e7ba39b 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..1fddd1b 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,3 @@ public void testSetDate() { } } -*/ diff --git a/src/testing/TestRunner.java b/src/testing/TestRunner.java index f26d18d..a9c7bac 100644 --- a/src/testing/TestRunner.java +++ b/src/testing/TestRunner.java @@ -1,6 +1,6 @@ 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; @@ -17,4 +17,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..50bd596 100644 --- a/src/testing/TestSuite.java +++ b/src/testing/TestSuite.java @@ -1,6 +1,6 @@ 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; @@ -12,4 +12,3 @@ public class TestSuite { } -*/ diff --git a/src/testing/TestTrain.java b/src/testing/TestTrain.java index 688df5c..d77ab2f 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() { } } -*/ +