diff --git a/AboutUs.java b/AboutUs.java new file mode 100644 index 0000000..af55a76 --- /dev/null +++ b/AboutUs.java @@ -0,0 +1,68 @@ +package Travel; + +import java.awt.EventQueue; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextPane; +import java.awt.Font; +import java.awt.Image; + +public class AboutUs { + + JFrame Aboutus_frame; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + AboutUs window = new AboutUs(); + window.Aboutus_frame.setVisible(true); + window.Aboutus_frame.setLocationRelativeTo(null); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public AboutUs() { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize() { + Aboutus_frame = new JFrame(); + Aboutus_frame.setBounds(100, 100, 679, 496); + Aboutus_frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + Aboutus_frame.getContentPane().setLayout(null); + + JLabel lblNewLabel = new JLabel(""); + Image images = new ImageIcon(this.getClass().getResource("about.png")).getImage().getScaledInstance(581,410, Image.SCALE_DEFAULT); + lblNewLabel.setIcon(new ImageIcon(images)); + lblNewLabel.setBounds(44, 10, 641, 441); + Aboutus_frame.getContentPane().add(lblNewLabel); + +// JTextPane textPane = new JTextPane(); +// textPane.setFont(new Font("Tahoma", Font.PLAIN, 17)); +// textPane.setBounds(0, 0, 651, 451); +// Aboutus_frame.getContentPane().add(textPane); +// textPane.setText("Who We Are?\r\nFounded in the year 2010 as Travel Planner. The Travel Planner is with its professionally " +// + "managed travel engine specializes mainly in providing services such as Holidays Packages , Domestic and " +// + "International Flight Booking, Bus Booking, Hotel Reservations , Domestic and International Tailor maid Tours , " +// + "Honeymoon Package, Visa. These services are delivered underneath the supervision of deft executives to retain " +// + "their consistency and superiority at the doorsteps of our esteemed clients.\r\n\r\nTravel Planner, is active " +// + "across to provide a world-class travel experience with dedication. We always aim to offer exciting experiences, " +// + "the best programmes, meticulously planned itineraries and all inclusive tours conducted by professional, " +// + "experienced, enthusiastic and seasoned tour managers."); + } +} diff --git a/Admin.java b/Admin.java new file mode 100644 index 0000000..5c3fdd4 --- /dev/null +++ b/Admin.java @@ -0,0 +1,219 @@ +package Travel; + +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JTextField; +import javax.swing.JButton; + +public class Admin { + + private JFrame frame; + private JTextField txtaddcity; + private JTextField txtremovecity; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + Admin window = new Admin(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public Admin() { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize() { + frame = new JFrame(); + frame.setBounds(100, 100, 749, 479); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().setLayout(null); + + JLabel lblNewLabel = new JLabel("Enter city to add:"); + lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 15)); + lblNewLabel.setBounds(86, 76, 172, 31); + frame.getContentPane().add(lblNewLabel); + + txtaddcity = new JTextField(); + txtaddcity.setBounds(249, 84, 96, 19); + frame.getContentPane().add(txtaddcity); + txtaddcity.setColumns(10); + + JLabel lblEnterCityTo = new JLabel("Enter city to remove:"); + lblEnterCityTo.setFont(new Font("Tahoma", Font.PLAIN, 15)); + lblEnterCityTo.setBounds(86, 203, 172, 31); + frame.getContentPane().add(lblEnterCityTo); + + txtremovecity = new JTextField(); + txtremovecity.setColumns(10); + txtremovecity.setBounds(249, 211, 96, 19); + frame.getContentPane().add(txtremovecity); + + JButton btnNewButton = new JButton("Add"); + btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 15)); + btnNewButton.setBounds(154, 149, 85, 21); + frame.getContentPane().add(btnNewButton); + + JButton btnRemove = new JButton("Remove"); + btnRemove.setFont(new Font("Tahoma", Font.BOLD, 15)); + btnRemove.setBounds(134, 257, 125, 21); + frame.getContentPane().add(btnRemove); + + JButton btnRemove_1 = new JButton("See all cities"); + btnRemove_1.setFont(new Font("Tahoma", Font.BOLD, 15)); + btnRemove_1.setBounds(130, 356, 246, 43); + frame.getContentPane().add(btnRemove_1); + } +} + + +//package Travel; +// +//import java.util.*; +// +//public class Admin { +// String city55; +// String city2; +// String c1[]; +// int num_city; +// City check_city1,Remov_city; +// Userr userinfo = new Userr(); +// Graph busNetwork = new Graph(true,true,true,true,true,true,false); +// Scanner s = new Scanner(System.in); +// +// //Method for Admin login to check whether the entered password is correct or not +// String Checkpassword(String password) { +// Scanner scan=new Scanner(System.in); +// int exit=0; +// while(!password.equals("sam")){ +// System.out.print("\nINCORRECT PASSWORD\nTO EXIT PRESS 1: "); +// exit=scan.nextInt(); +// if(exit==1) { +// System.out.println("YOU HAVE EXIT SUCCESSFULLY!!"); +// break; +// } +// else { +// System.out.print("\nPLEASE ENTER VALID PASSWORD: "); +// password = scan.next(); +// } +// } +// return password; +// } +// public void AdminLogin() { +// int bc; +// int bd; +// int bt; +// int tc; +// int td; +// int tt; +// int choice = 0; +// System.out.println("\nAdmin is Loged in"); +// do { +// System.out.println("\n**Enter the following choice**"); +// System.out.println("0. Exit"); +// System.out.println("1. Show booked trips"); +// System.out.println("2. Add a city to your trip"); +// System.out.println("3. Remove a city from planed trip"); +// System.out.println("4. Show cities present"); +// System.out.println("5. user to check"); +// choice = s.nextInt(); +// +// switch (choice) { +// case 0 : +// break; +// case 1: +// System.out.println("\nShowing the trips"); +// userinfo.prevTrip(); +// System.out.println("\nDo you want to know the path"); +// System.out.println("1. yes / 2. No"); +// int ch = s.nextInt(); +// if (ch == 1) { +// userinfo.tripPath(); +// } else { +// break;} +// break; +// case 2: +// System.out.println("\n*Adding city to trip*"); +// System.out.print("\nEnter the City: "); +// city55 = s.next(); +// City city55station = busNetwork.addCity(city55); +// System.out.println("\nEnter the number of routes you want to create"); +// int n = s.nextInt(); +// num_city = n; +// int i = 0; +// c1 = new String[50]; +// while (n != 0) { +// System.out.println("\nEnter the nearest "+n+" cities"); +// System.out.print("Enter " + (i+1) + " city : "); +// c1[i] = s.next(); +// check_city1 = userinfo.checkCity(c1[i]); +// if (userinfo.checkCity(c1[i]) != null) { +// System.out.println("\nFor city " + c1[i] + "\nEnter the Routes cost and time"); +// System.out.print("\nBus cost: "); +// bc = s.nextInt(); +// System.out.print("Bus distance: "); +// bd = s.nextInt(); +// System.out.print("Bus time: "); +// bt = s.nextInt(); +// System.out.print("train cost: "); +// tc = s.nextInt(); +// System.out.print("train distance: "); +// td = s.nextInt(); +// System.out.print("train time: "); +// tt = s.nextInt(); +// } else { +// System.out.println("City not there. try for some other 5"); +// break; +// } +// busNetwork.addRoute(city55station, check_city1, bd, td, bc, tc, bt, tt); +// +// System.out.println("City is successfully added"); +// i++; +// n--; +// } +// break; +// +// case 3: +// System.out.println("\nRemoving the city from planned trip"); +// System.out.print("Enter the City to remove: "); +// city2 = s.next(); +// for(int j=0;j routes; + int flag=0; + //Constructor of class City + City(String city){ + this.city = city; + this.routes = new LinkedList(); + } + + public void addRoutes(City endCity,Integer busDist,Integer trainDist,Integer busCost, + Integer trainCost,Integer busTime,Integer trainTime) { + this.routes.add(new Routes(this,endCity,busDist,trainDist,busCost,trainCost,busTime,trainTime)); + } + + public void removeRoutes(City endCity) { + //The arrow operator is used to create lambda expressions, + //linking/separating parameters with the lambda body + this.routes.removeIf(routes -> routes.getEnd().equals(endCity)); + } + + //helper methods + public String getCity() { + return this.city; + } + + public LinkedList getRoutes(){ + return this.routes; + } + + + //To show the weights + public void print(boolean showDist) { + + String message=" "; + + + if(this.routes.size() == 0) { + + System.out.println(this.city+"--->"); + return; + } + + + for(int i=0;i"; + } + + + + message += this.routes.get(i).getEnd().city; + + if(showDist) { + message += "("+ " BusDist"+this.routes.get(i).getBusDist()+" TrainDist"+this.routes.get(i).getTrainDist()+" BusCost"+ + this.routes.get(i).getBusCost()+" TrainCost"+ + this.routes.get(i).getTrainCost()+" BusTime"+this.routes.get(i).getBusTime()+ + " TrainTime"+this.routes.get(i).getTrainTime()+")"; + + } + + + if(i!= this.routes.size() - 1) { + message += ", "; + } + } + System.out.println(message); + + } + + +} + diff --git a/ContactUs.java b/ContactUs.java new file mode 100644 index 0000000..250893c --- /dev/null +++ b/ContactUs.java @@ -0,0 +1,56 @@ +package Travel; + +import java.awt.EventQueue; +import java.awt.Image; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import java.awt.BorderLayout; + +public class ContactUs { + + JFrame frame; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + ContactUs window = new ContactUs(); + window.frame.setVisible(true); + window.frame.setLocationRelativeTo(null); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public ContactUs() { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize() { + frame = new JFrame(); + frame.setBounds(100, 100, 605, 458); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.getContentPane().setLayout(null); + + JLabel lblNewLabel = new JLabel(""); + Image images = new ImageIcon(this.getClass().getResource("contact_us.png")).getImage().getScaledInstance(581,410, Image.SCALE_DEFAULT); + lblNewLabel.setIcon(new ImageIcon(images)); + lblNewLabel.setBounds(0, 0, 591, 421); + frame.getContentPane().add(lblNewLabel); + + } + +} diff --git a/Dijikstra.java b/Dijikstra.java new file mode 100644 index 0000000..cf7a435 --- /dev/null +++ b/Dijikstra.java @@ -0,0 +1,323 @@ +package Travel; +import java.util.*; + +public class Dijikstra { + static Integer alternative,alternative1,alternative2; + static int z=0; + static int r=0; + static String a=null; + public static Dictionary[] dijikstra(Graph g, City startingcity) { + Dictionary distances = new Hashtable<>(); + Dictionary previous = new Hashtable<>(); + PriorityQueue queue = new PriorityQueue(); + + queue.add(new QueueObject(startingcity, 0)); + + for (City v: g.getCities()) { + if (v != startingcity) { + distances.put(v.getCity(), Integer.MAX_VALUE); + } + previous.put(v.getCity(), new City("Null")); + } + + distances.put(startingcity.getCity(),0); + + while (queue.size() != 0) { + City current = queue.poll().city; + for (Routes e: current.getRoutes()) { +// Userr uu=new Userr(); + + //System.out.println(z); + if(z==1) { + alternative = distances.get(current.getCity()) + e.getBusDist(); + + } + else if(z==2) { + alternative = distances.get(current.getCity()) + e.getBusCost(); + + } + else if(z==3) { + alternative = distances.get(current.getCity()) + e.getBusTime(); + + } + else if(z==4) { + alternative = distances.get(current.getCity()) + e.getTrainDist(); + + } + else if(z==5) { + alternative = distances.get(current.getCity()) + e.getTrainCost(); + + } + else if(z==6) { + alternative = distances.get(current.getCity()) + e.getTrainTime(); + + + } +// Integer alternative = distances.get(current.getCity()) + e.getBusDist(); + String neighborValue = e.getEnd().getCity(); + if (alternative < distances.get(neighborValue)) { + distances.put(neighborValue, alternative); + previous.put(neighborValue, current); + queue.add(new QueueObject(e.getEnd(), distances.get(neighborValue))); + } + } + } + return new Dictionary[]{distances, previous}; + } + + public static String shortestPathBetween(Graph g, City startingcity,City targetcity) { + int Busdist=0; + int Buscost=0; + int Bustime=0; + int Traindist=0; + int Traincost=0; + int Traintime=0; + Trip trip = new Trip(null,null,null,null,null,null); + Dictionary[] dijikstraDictionaries = dijikstra(g, startingcity); + Dictionary distances = dijikstraDictionaries[0]; + Dictionary previous = dijikstraDictionaries[1]; + + Integer distance = (Integer) distances.get(targetcity.getCity()); + // System.out.println("Shortest Distance between " + startingcity.getCity() + " and " + targetcity.getCity()); + //System.out.println(distance); + + ArrayList path = new ArrayList<>(); + City v = targetcity; + ArrayList path2 = new ArrayList<>(); + City v2 = targetcity; + while (v.getCity() != "Null") { + path.add(0, v); + v = (City) previous.get(v.getCity()); + } + while (v.getCity() != "Null") { + path.add(0, v); + v = (City) previous.get(v.getCity()); + } +String u=""; + while (v2.getCity() != "Null") {// + path2.add(v2); + + for(Routes e : v2.getRoutes()) { + + if(z==1) { + //For bus distance + for(Routes e1 : v2.getRoutes()) { + // System.out.println("start: "+e1.getStart().getCity()); + // System.out.println("end: "+e1.getEnd().getCity()); + if(e1.getStart().equals(v2) && e1.getEnd().equals((City) previous.get(v2.getCity()))) { + // System.out.println("1 "+v2.getCity()); + // System.out.println("2 "+v2.getRoutes()); + // System.out.println("3 "+e1.getBusCost()); + Buscost += e1.getBusCost(); + Bustime += e1.getBusTime(); + } + } + } + if(z==2) { + //For bus cost + for(Routes e1 : v2.getRoutes()) { + if(e1.getStart().equals(v2) && e1.getEnd().equals((City) previous.get(v2.getCity()))) { + Busdist += e1.getBusDist(); + Bustime += e1.getBusTime(); + } + } + } + if(z==3) { + //For bus time + for(Routes e1 : v2.getRoutes()) { + if(e1.getStart().equals(v2) && e1.getEnd().equals((City) previous.get(v2.getCity()))) { + Busdist += e1.getBusDist(); + Buscost += e1.getBusCost(); + } + } + } + if(z==4) { + //For train distance + for(Routes e1 : v2.getRoutes()) { + if(e1.getStart().equals(v2) && e1.getEnd().equals((City) previous.get(v2.getCity()))) { + Traincost += e1.getTrainCost(); + Traintime += e1.getTrainTime(); + } + } + } + if(z==5) { + //for train cost + for(Routes e1 : v2.getRoutes()) { + if(e1.getStart().equals(v2) && e1.getEnd().equals((City) previous.get(v2.getCity()))) { + Traindist += e1.getTrainDist(); + Traintime += e1.getTrainTime(); + } + } + } + if(z==6) { + //for train time + for(Routes e1 : v2.getRoutes()) { + if(e1.getStart().equals(v2) && e1.getEnd().equals((City) previous.get(v2.getCity()))) { + Traindist += e1.getTrainDist(); + Traincost += e1.getTrainCost(); + } + } + } + + v2 = (City) previous.get(v2.getCity()); + } + if(v2==null) { + break; + } + }// + if(z==1) { + u=u+"\nBetween " + startingcity.getCity() + " and " + targetcity.getCity()+":\n\nShortest Distance:"+distance+" Km\n"+ + "Bus Cost: "+Buscost+" Rs\n"+"Bus Time: "+Bustime+" hr\n"; + System.out.println("\nBetween " + startingcity.getCity() + " and " + targetcity.getCity()); + System.out.println(distance+" Km"); + System.out.println("Bus Cost: "+Buscost+" Rs"); + System.out.println("Bus Time: "+Bustime+" hr"); + } + if(z==2) { + u=u+"\nBetween " + startingcity.getCity() + " and " + targetcity.getCity()+":\n\nCheapest Cost:"+distance+" Rs\n"+ + "Bus Distance: "+Busdist+" Km\n"+"Bus Time: "+Bustime+" hr\n"; + System.out.println("\nCheapest cost between " + startingcity.getCity() + " and " + targetcity.getCity()); + System.out.println(distance+" Rs"); + System.out.println("Bus Cost: "+Busdist+" Km"); + System.out.println("Bus Time: "+Bustime+" hr"); + } + if(z==3) { + u=u+"\nBetween " + startingcity.getCity() + " and " + targetcity.getCity()+":\n\nLeast Time:"+distance+" hr\n"+ + "Bus Distance: "+Busdist+" Km\n"+"Bus Cost: "+Buscost+" Rs\n"; + System.out.println("\nLeast Time between " + startingcity.getCity() + " and " + targetcity.getCity()); + System.out.println(distance+" hr"); + System.out.println("Bus Cost: "+Busdist+" Km"); + System.out.println("Bus Time: "+Buscost+" Rs"); + } + if(z==4) { + u=u+"\nBetween " + startingcity.getCity() + " and " + targetcity.getCity()+":\n\nShortest Distance:"+distance+" Km\n"+ + "Train Cost: "+Traincost+" Rs\n"+"Train Time: "+Traintime+" hr\n"; + System.out.println("\nShortest Distance between " + startingcity.getCity() + " and " + targetcity.getCity()); + System.out.println(distance+" Km"); + System.out.println("Train Cost: "+Traincost+" Rs"); + System.out.println("Train Time: "+Traintime+" hr"); + } + if(z==5) { + u=u+"\nBetween " + startingcity.getCity() + " and " + targetcity.getCity()+":\n\nCheapest Cost:"+distance+" Rs\n"+ + "Train Distance: "+Traindist+" Km\n"+"Train Time: "+Traintime+" hr\n"; + System.out.println("\nCheapest Cost between " + startingcity.getCity() + " and " + targetcity.getCity()); + System.out.println(distance+" Rs"); + System.out.println("Train Cost: "+Traindist+" Km"); + System.out.println("Train Time: "+Traintime+" hr"); + } + if(z==6) { + u=u+"\nBetween " + startingcity.getCity() + " and " + targetcity.getCity()+":\n\nLeast Time:"+distance+" hr\n"+ + "Train Distance: "+Traindist+" Km\n"+"Bus Cost: "+Traincost+" Rs\n"; + System.out.println("\nLeast Time between " + startingcity.getCity() + " and " + targetcity.getCity()); + System.out.println(distance+" hr"); + System.out.println("Train Cost: "+Traindist+" Km"); + System.out.println("Train Time: "+Traincost+" Rs"); + }// + System.out.println("Shortest Path: "); + int i=1; + String ii="Shortest Path: "; + for (City pathVertex: path){ + if(i "; + // System.out.print(pathVertex.getCity()+" -> "); + i++;} + else if(i==path.size()) { + //System.out.println(pathVertex.getCity()); + ii=ii+pathVertex.getCity(); + } + } +return u+"\n"+ii; + } + public static void shortestPathBetweennn(Graph g, City startingcity,City targetcity) { + int cost=0; + Trip trip = new Trip(null,null,null,null,null,null); + + Dictionary[] dijikstraDictionaries = dijikstra(g, startingcity); + Dictionary distances = dijikstraDictionaries[0]; + Dictionary previous = dijikstraDictionaries[1]; + + Integer distance = (Integer) distances.get(targetcity.getCity()); + System.out.println("\nShortest Distance between " + startingcity.getCity() + " and " + targetcity.getCity()); + System.out.println(distance); + + ArrayList path = new ArrayList<>(); + City v = targetcity; + + while (v.getCity() != "Null") { + path.add(0, v); + v = (City) previous.get(v.getCity()); + } +// Trip.storedTrip = new LinkedList(); + //String a=null; + System.out.println(a); + a="Shortest Path: "; + int i=1; + for (City pathVertex: path){ + //a=a+pathVertex.getCity()+" -> "; + if(i "; + i++; + } +//// System.out.print(pathVertex.getCity()+" -> "); +//// i++;} + else if(i==path.size()) { + a=a+pathVertex.getCity(); + } +// System.out.println(pathVertex.getCity()); + } +// } + + System.out.println("\nShortest Path"); + //trip.storedTrip = new String[50]; +// int z=0; + System.out.println(a); + //trip.storedTrip[0]=a; + // System.out.println(trip.storedTrip[0]); + System.out.println("r"+r); + r++; +// for (City pathVertex: path){ +// System.out.println(pathVertex.getCity()); +// trip.storedTrip[i]=pathVertex.getCity(); +// i++; +// +//// for(Routes e : pathVertex.getRoutes()) { +//// if(z==1) { +//// cost += e.getBusCost(); +//// } +//// } +// } + System.out.println("\nCost is : "+cost); + //For printing time and cost + + } + + public static int shortestPathBetweenn(Graph g, City startingcity,City targetcity) { + Dictionary[] dijikstraDictionaries = dijikstra(g, startingcity); + Dictionary distances = dijikstraDictionaries[0]; + Dictionary previous = dijikstraDictionaries[1]; + + Integer distance = (Integer) distances.get(targetcity.getCity()); + +return distance; + } + + public static void dijikstraResultPrinter(Dictionary[] d){ + System.out.println("Distances:\n"); + for (Enumeration keys = d[0].keys(); keys.hasMoreElements();){ + String nextKey = keys.nextElement().toString(); + System.out.println(nextKey + ": " + d[0].get(nextKey)); + } + System.out.println("\nPrevious:\n"); + for (Enumeration keys = d[1].keys(); keys.hasMoreElements();) + { + String nextKey = keys.nextElement().toString(); + City nextcity = (City) d[1].get(nextKey); + System.out.println(nextKey + ": " + nextcity.getCity()); + } + } +} + + + + + diff --git a/Graph.java b/Graph.java new file mode 100644 index 0000000..55e14b2 --- /dev/null +++ b/Graph.java @@ -0,0 +1,211 @@ +package Travel; + +import java.util.LinkedList; +import java.util.Scanner; +public class Graph { + //data-city,Edges-Routes,Vertex-City,vertex-city + static LinkedList cities; + boolean isBusDist,isTrainDist,isBusCost,isTrainCost,isBusTime,isTrainTime;//isbusDist + boolean isDirected; + + public Graph(boolean isBusDist,boolean isTrainDist,boolean isBusCost,boolean isTrainCost,boolean isBusTime,boolean isTrainTime + ,boolean isDirected) { + this.cities=new LinkedList(); + this.isBusDist=isBusDist; + this.isTrainDist=isTrainDist; + this.isBusCost=isBusCost; + this.isTrainCost=isTrainCost; + this.isBusTime=isBusTime; + this.isTrainTime=isTrainTime; + this.isDirected=isDirected; + } + + public City addCity(String city) { + City newCity=new City(city); + this.cities.add(newCity); + return newCity; + } + + public void addRoute(City city1,City city2,Integer busDist,Integer trainDist,Integer busCost, + Integer trainCost,Integer busTime,Integer trainTime) {//provides abstraction + //ata purta fakt busdist consider kela in future will add + if(!this.isBusDist) {//if dist not given consider it as null + busDist=null; + } + city1.addRoutes(city2,busDist,trainDist,busCost, + trainCost,busTime,trainTime); + if(!this.isDirected) { + city2.addRoutes(city1,busDist,trainDist,busCost, + trainCost,busTime,trainTime); + } + } +// public void removeRoute(City city1,City city2) { +// city1.removeRoutes(city2); +// if(!this.isDirected) { +// city2.removeRoutes(city1); +// } +// } + public void removeRoute(String city1Name, String city2Name) { + City city1 = getCityByValue(city1Name); + City city2 = getCityByValue(city2Name); + if (city1 == null || city2 == null) { + System.out.println("One or both cities do not exist."); + return; + } + city1.removeRoutes(city2); + if (!this.isDirected) { + city2.removeRoutes(city1); + } + System.out.println("Route between " + city1.getCity() + " and " + city2.getCity() + " has been removed."); + } + public void removeCity(City city) { + this.cities.remove(city); + } + + public LinkedList getCities(){ + return this.cities; + } + + public boolean isBusDist() { + return this.isBusDist; + } + + public boolean isTrainDist() { + return this.isTrainDist; + } + + // public boolean isBusCost() { + // return this.isBusCost; + // } + + public boolean isTrainCost() { + return this.isTrainCost; + } + + public boolean isBusTime() { + return this.isBusTime; + } + + public boolean isTrainTime() { + return this.isTrainTime; + } + + public boolean isDirected() { + return this.isDirected; + } + + + public City getCityByValue(String value) {//to check whether city + //is present or not + //System.out.println("hi"); + for(City c:this.cities) { + //System.out.println("hi"); + if(c.getCity().equals(value)) { + return c; + + } + + } + return null; + + + + + } + + public void print() { + int i=0; + for(City c: this.cities) { + if(i<1) { + c.print(isBusDist); + i++;}//fakt isBusDist sathi lihila in future baki karu + } + + } + + + String Checkpassword(String password) { + Scanner scan=new Scanner(System.in); + int exit=0; + while(!password.equals("sam")){ + System.out.print("\nTO EXIT PRESS 1: "); + exit=scan.nextInt(); + if(exit==1) { + System.out.println("YOU HAVE EXIT SUCCESSFULLY!!"); + break; + } + else { + System.out.print("\nPLEASE ENTER VALID PASSWORD: "); + password = scan.next(); + } + } + + return password; + } + public void addcityy() { + Graph busNetwork = new Graph(true, true, true, true, true, true, false); + //when isDirected is false undirected is considered + //this line might be wrong was like isBusDist:true but was giving error + //so wrote like this + //Userr user=new Userr(); + City MumbaiStation = busNetwork.addCity("Mumbai"); + City PuneStation = busNetwork.addCity("Pune"); + City NagpurStation = busNetwork.addCity("Nagpur"); + City DelhiStation = busNetwork.addCity("Delhi"); + + + + busNetwork.addRoute(MumbaiStation, PuneStation, 40, 30, 50, 30, 1, 2); + busNetwork.addRoute(MumbaiStation, DelhiStation, 40, 30, 50, 30, 1, 2); + busNetwork.addRoute(PuneStation, NagpurStation, 40, 30, 50, 30, 1, 2); + } + public static void main(String[] args) { + Graph busNetworkk = new Graph(true, true, true, true, true, true, false); + //when isDirected is false undirected is considered + //this line might be wrong was like isBusDist:true but was giving error + //so wrote like this + Userr user=new Userr(); +// City MumbaiStation = busNetwork.addCity("Mumbai"); +// City PuneStation = busNetwork.addCity("Pune"); +// City NagpurStation = busNetwork.addCity("Nagpur"); +// City DelhiStation = busNetwork.addCity("Delhi"); +// +// +// +// busNetwork.addRoute(MumbaiStation, PuneStation, 40, 30, 50, 30, 1, 2); +// busNetwork.addRoute(MumbaiStation, DelhiStation, 40, 30, 50, 30, 1, 2); +// busNetwork.addRoute(PuneStation, NagpurStation, 40, 30, 50, 30, 1, 2); + + busNetworkk.addcityy(); + Scanner scan=new Scanner(System.in); + int choice=0; + + System.out.println("********************WELCOME TO TRAVEL PLANNER********************" + + "\n1.ADMIN LOGIN\n2.USER LOGIN\n"); + System.out.print("ENTER YOUR CHOICE: "); + choice=scan.nextInt(); + scan.nextLine(); + switch(choice) { + case 1: + Bus1 bu=new Bus1(); + System.out.println(bu.busdist); + String password; + System.out.print("\nPLEASE ENTER PASSWORD: "); + password = scan.nextLine(); + password=busNetworkk.Checkpassword(password); + busNetworkk.print(); + break;//sysout ctr+space + case 2: + + user.userLogin(); + break; + default: + System.out.println("PLEASE ENTER VALID CHOICE!!"); + } + + //busNetwork.print(); + //System.out.println(City.routes.size()); + } +} + + diff --git a/Help.java b/Help.java new file mode 100644 index 0000000..23ab71b --- /dev/null +++ b/Help.java @@ -0,0 +1,52 @@ +package Travel; + +import java.awt.EventQueue; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class Help { + + JFrame Help_frame; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + Help window = new Help(); + window.Help_frame.setVisible(true); + window.Help_frame.setLocationRelativeTo(null); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public Help() { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize() { + Help_frame = new JFrame(); + Help_frame.setBounds(100, 100, 1251, 572); + Help_frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + Help_frame.getContentPane().setLayout(null); + + JLabel lblNewLabel = new JLabel(""); + ImageIcon img=new ImageIcon(this.getClass().getResource("Screenshot 2023-04-27 170203.png")); + lblNewLabel.setIcon(img); + lblNewLabel.setBounds(-128, 10, 1369, 525); + Help_frame.getContentPane().add(lblNewLabel); + } +} diff --git a/PlacesToVisit.java b/PlacesToVisit.java new file mode 100644 index 0000000..bc272ae --- /dev/null +++ b/PlacesToVisit.java @@ -0,0 +1,82 @@ +package Travel; +import java.awt.Color; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; +import java.awt.Font; + + +public class PlacesToVisit extends JFrame{ + + JLabel pic; + Timer tm; + int x = 0; + //Images Path In Array + String[] list = { + "C:\\Users\\nisha\\OneDrive\\Desktop\\Buffer\\agrafort1.jpg",//0 + "D:\\Downloads C_to_D\\gateway-of-india.jpg",//1 + + "D:\\Downloads C_to_D\\Maharajahs-Palace-in-Mysore.jpg",//3 + "D:\\Downloads C_to_D\\golentemple.jpg",//4 + "D:\\Downloads C_to_D\\goaa.jpg",//5 + "D:\\Downloads C_to_D\\placetovisit.jpg",//6 + "D:\\Downloads C_to_D\\tajmahl1.jpg"//2 + }; + + public PlacesToVisit(){ + + super("Java SlideShow"); + //setSize(80,90); + pic = new JLabel(); + pic.setBounds(0, 0, 839, 572); + + //Call The Function SetImageSize + SetImageSize(6); + //set a timer + tm = new Timer(2000,new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + SetImageSize(x); + x += 1; + if(x >= list.length ) + x = 0; + } + }); + getContentPane().add(pic); + tm.start(); + getContentPane().setLayout(null); + setSize(847, 658); + getContentPane().setBackground(Color.decode("#bdb67b")); + + JButton btnKnowYourUniverse = new JButton("Know About Places"); + btnKnowYourUniverse.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + aboutplacess a=new aboutplacess(); + a.a_pframe.setVisible(true); + a.a_pframe.setLocationRelativeTo(null); + } + }); + btnKnowYourUniverse.setFont(new Font("Yu Gothic UI Semilight", Font.BOLD, 15)); + btnKnowYourUniverse.setBounds(319, 571, 268, 48); + getContentPane().add(btnKnowYourUniverse); + setLocationRelativeTo(null); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setVisible(true); + } + //create a function to resize the image + public void SetImageSize(int i){ + ImageIcon icon = new ImageIcon(list[i]); + Image img = icon.getImage(); + Image newImg = img.getScaledInstance(pic.getWidth(), pic.getHeight(), Image.SCALE_SMOOTH); + ImageIcon newImc = new ImageIcon(newImg); + pic.setIcon(newImc); + } + +public static void main(String[] args){ + + PlacesToVisit skySlideshow = new PlacesToVisit(); + skySlideshow.setVisible(true); + skySlideshow.setLocationRelativeTo(null);} +} \ No newline at end of file diff --git a/QueueObject.java b/QueueObject.java new file mode 100644 index 0000000..d04bc87 --- /dev/null +++ b/QueueObject.java @@ -0,0 +1,26 @@ +package Travel; + +public class QueueObject implements Comparable{ +public City city; +public int priority; +public QueueObject(City c,int p) { + this.city=c; + this.priority=p; +} + +@Override + +public int compareTo(QueueObject o) { + if(this.priority==o.priority) { + return 0; + } + else if(this.priority>o.priority) { + return 1; + } + else { + return -1; + } +} +} + + diff --git a/Routes.java b/Routes.java new file mode 100644 index 0000000..f258380 --- /dev/null +++ b/Routes.java @@ -0,0 +1,50 @@ +package Travel; + +public class Routes { + City start; + City end; + Integer busDist; + Integer trainDist; + Integer busCost; + Integer trainCost; + Integer busTime; + Integer trainTime; + + //The reason of using Integer is that we can put null if we want to + Routes(City start,City end,Integer busDist,Integer trainDist,Integer busCost,Integer trainCost, + Integer busTime,Integer trainTime){ + this.start = start; + this.end = end; + this.busDist = busDist; + this.trainDist = trainDist; + this.busCost = busCost; + this.trainCost = trainCost; + this.busTime = busTime; + this.trainTime = trainTime; + } + + public City getStart() { + return this.start; + } + public City getEnd() { + return this.end; + } + public Integer getBusDist() { + return this.busDist; + } + public Integer getTrainDist() { + return this.trainDist; + } + public Integer getBusCost() { + return this.busCost; + } + public Integer getTrainCost() { + return this.trainCost; + } + public Integer getBusTime() { + return this.busTime; + } + public Integer getTrainTime() { + return this.trainTime; + } +} \ No newline at end of file diff --git a/Screenshot 2023-04-27 170133.png b/Screenshot 2023-04-27 170133.png new file mode 100644 index 0000000..f7fb7b6 Binary files /dev/null and b/Screenshot 2023-04-27 170133.png differ diff --git a/Screenshot 2023-04-27 170203.png b/Screenshot 2023-04-27 170203.png new file mode 100644 index 0000000..c364a3f Binary files /dev/null and b/Screenshot 2023-04-27 170203.png differ diff --git a/Screenshot 2023-04-27 170222.png b/Screenshot 2023-04-27 170222.png new file mode 100644 index 0000000..6a1caff Binary files /dev/null and b/Screenshot 2023-04-27 170222.png differ diff --git a/Train1.java b/Train1.java new file mode 100644 index 0000000..12c2bfa --- /dev/null +++ b/Train1.java @@ -0,0 +1,274 @@ +//inside receipt name,dist,cost,time all info of customer +package Travel; +import java.util.Scanner; +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; + +import java.awt.Font; +import javax.swing.JTextField; +import javax.swing.JScrollPane; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JRadioButton; +import javax.swing.JComboBox; +import javax.swing.DefaultComboBoxModel; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JTextArea; +import java.awt.Color; +import javax.swing.JTextPane; + +public class Train1 { + int choice1; + //int y=0; + int w=0; + static int routeType; + String traindist=null,traincost=null,traintime=null; + int traindistt=0,traincostt=0,traintimee=0; + JFrame Train1_frame; + private JTextField txtleavingfrom; + private JTextField txtgoingto; + String startLocation,destination; + String route; + static City check_sLocation = null; + static City check_destination = null; + Scanner scn = new Scanner(System.in); + Graph graph=new Graph(true,true,true,true,true,true,true); +// graph.addcityy(); +// + String check_route; + private JTextField textField; + private JTextField textField_1; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + Train1 window = new Train1(); + window.Train1_frame.setVisible(true); + window.Train1_frame.setLocationRelativeTo(null); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public Train1() { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize() { + Train1_frame = new JFrame(); + Train1_frame.setBounds(100, 100, 727, 411); + Train1_frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + Train1_frame.getContentPane().setLayout(null); + + JPanel panel = new JPanel(); + panel.setBorder(new TitledBorder(null, "Book Train", TitledBorder.LEADING, TitledBorder.TOP, null, null)); + panel.setBounds(10, 20, 696, 344); + Train1_frame.getContentPane().add(panel); + panel.setLayout(null); + + txtleavingfrom = new JTextField(); + startLocation=txtleavingfrom.getText(); + txtleavingfrom.setBounds(185, 23, 155, 31); + panel.add(txtleavingfrom); + txtleavingfrom.setColumns(10); + + txtgoingto = new JTextField(); + destination=txtgoingto.getText(); + txtgoingto.setBounds(185, 69, 155, 31); + panel.add(txtgoingto); + txtgoingto.setColumns(10); + + +// JComboBox txtroutetype = new JComboBox(); +// txtroutetype.setFont(new Font("Tahoma", Font.PLAIN, 20)); +// txtroutetype.setModel(new DefaultComboBoxModel(new String[] {"Shortest Distance", "Least Time", "Cheapest Cost"})); +// txtroutetype.setEditable(true); +// txtroutetype.setBorder(null); +// txtroutetype.setBounds(10, 126, 220, 46); +// panel.add(txtroutetype); + + JComboBox txtroutetype = new JComboBox(); + txtroutetype.setFont(new Font("Tahoma", Font.PLAIN, 20)); + txtroutetype.setModel(new DefaultComboBoxModel(new String[] {"Shortest Distance", "Least Time", "Cheapest Cost"})); + txtroutetype.setEditable(true); + txtroutetype.setBorder(null); + txtroutetype.setBounds(10, 155, 220, 46); + panel.add(txtroutetype); + + //txtloader.setText("Cost : "+Integer.toString(buscost)+"\nDistance : 0"+"\nTime : 0"); + JTextPane txtloader = new JTextPane(); + txtloader.setFont(new Font("Txt_IV50", Font.PLAIN, 17)); + txtloader.setBounds(405, 35, 281, 299); + panel.add(txtloader); + + JTextPane txtpnClickSearchFor = new JTextPane(); + txtpnClickSearchFor.setFont(new Font("Tw Cen MT Condensed", Font.BOLD, 17)); + txtpnClickSearchFor.setText(" CLICK SEARCH FOR TRIP INFORMATION"); + txtpnClickSearchFor.setBounds(405, 10, 281, 21); + panel.add(txtpnClickSearchFor); + + JButton Clear = new JButton("Clear"); + Clear.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + txtleavingfrom.setText(""); + txtgoingto.setText(""); + txtloader.setText(" "); + txtleavingfrom.requestFocus(); + } + }); + Clear.setForeground(new Color(25, 25, 112)); + Clear.setFont(new Font("Tahoma", Font.PLAIN, 20)); + Clear.setBackground(Color.ORANGE); + Clear.setBounds(10, 255, 119, 53); + panel.add(Clear); + + JButton btnNewButton_4_2 = new JButton("Book Bus"); + btnNewButton_4_2.setForeground(new Color(25, 25, 112)); + btnNewButton_4_2.setFont(new Font("Tahoma", Font.PLAIN, 20)); + btnNewButton_4_2.setBackground(Color.ORANGE); + btnNewButton_4_2.setBounds(145, 255, 119, 53); + panel.add(btnNewButton_4_2); + + JButton btnNewButton_4_1 = new JButton("Search"); + btnNewButton_4_1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + graph.addcityy(); + if(graph.getCityByValue(txtleavingfrom.getText())==null&&graph.getCityByValue(txtgoingto.getText())==null) { + JOptionPane.showMessageDialog(null, "Both Cities not present Enter again!!!!!!"); + txtleavingfrom.setText(""); + txtgoingto.setText(""); + txtleavingfrom.requestFocus(); + } + else if(graph.getCityByValue(txtleavingfrom.getText())==null&&graph.getCityByValue(txtgoingto.getText())!=null) { + JOptionPane.showMessageDialog(null, "Leaving City not present Enter again!!!!!!"); + txtleavingfrom.setText(""); + txtleavingfrom.requestFocus(); + } + else if(graph.getCityByValue(txtleavingfrom.getText())!=null&&graph.getCityByValue(txtgoingto.getText())==null){ + if(graph.getCityByValue(txtgoingto.getText())==null) { + JOptionPane.showMessageDialog(null, "Going City not present Enter again!!!!!!"); + txtgoingto.setText(""); + txtgoingto.requestFocus(); + } + } + + if(txtroutetype.getSelectedItem().toString() == "Shortest Distance") {//dist,cost,time//132 + w=1; + Dijikstra dj =new Dijikstra(); + dj.z=4; + traindist=dj.shortestPathBetween(graph,graph.getCityByValue(txtleavingfrom.getText()), + graph.getCityByValue(txtgoingto.getText())); + //System.out.println(y); + txtloader.setText(traindist); + + } + else if(txtroutetype.getSelectedItem().toString() == "Least Time") { + w=2; + Dijikstra dj =new Dijikstra(); + dj.z=6; + traintime=dj.shortestPathBetween(graph,graph.getCityByValue(txtleavingfrom.getText()), + graph.getCityByValue(txtgoingto.getText())); + //System.out.println(y); + txtloader.setText(traintime); + + } + else if(txtroutetype.getSelectedItem().toString() == "Cheapest Cost") { + w=3; + Dijikstra dj =new Dijikstra(); + dj.z=5; + traincost=dj.shortestPathBetween(graph,graph.getCityByValue(txtleavingfrom.getText()), + graph.getCityByValue(txtgoingto.getText())); + //System.out.println(y); + //JOptionPane.showMessageDialog(null, "buscost: "+buscost+"\n want to book press Book Bus"); + //txtloader.setText("Cost : "+Integer.toString(buscost)+"\nDistance : 0"+"\nTime : 0"); + txtloader.setText(traincost); + + } + } + }); + btnNewButton_4_1.setForeground(new Color(25, 25, 112)); + btnNewButton_4_1.setFont(new Font("Tahoma", Font.PLAIN, 20)); + btnNewButton_4_1.setBackground(Color.ORANGE); + btnNewButton_4_1.setBounds(276, 255, 119, 53); + panel.add(btnNewButton_4_1); + +// + + textField = new JTextField(); + textField.setText("Source"); + textField.setFont(new Font("Segoe Print", Font.PLAIN, 20)); + textField.setColumns(10); + textField.setBorder(null); + textField.setBounds(10, 23, 79, 36); + panel.add(textField); + + textField_1 = new JTextField(); + textField_1.setText("Destination"); + textField_1.setFont(new Font("Segoe Print", Font.PLAIN, 20)); + textField_1.setColumns(10); + textField_1.setBorder(null); + textField_1.setBounds(10, 69, 138, 36); + panel.add(textField_1); + } + public City checkCity(String city) { + City checksLocation=null; + checksLocation = graph.getCityByValue(city); + int choice=0; + while(checksLocation==null) { + System.out.println("\nCITY NOT PRESENT"); + System.out.print("STILL WANT TO CONTINUE???\nPRESS 1 FOR EXIT: "); + choice = scn.nextInt(); + if(choice!=1) { + System.out.print("\nENTER START LOCATION: "); + city = scn.next(); + checksLocation = graph.getCityByValue(city + ); + } + else { + System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); + break; + } + + } + return checksLocation; + } + public City checkDestination(String city) { + City checksLocation=null; + checksLocation = graph.getCityByValue(city); + int choice=0; + while(checksLocation==null) { + System.out.println("\nCITY NOT PRESENT"); + System.out.print("STILL WANT TO CONTINUE???\nPRESS 1 FOR EXIT: "); + choice = scn.nextInt(); + if(choice!=1) { + System.out.print("\nENTER DESTINATION: "); + city = scn.next(); + checksLocation = graph.getCityByValue(city); + } + else { + System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); + break; + } + + } + return checksLocation; + } +} diff --git a/User.java b/User.java new file mode 100644 index 0000000..4bcec0e --- /dev/null +++ b/User.java @@ -0,0 +1,200 @@ +package Travel; + +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import java.awt.Font; +import javax.swing.JLabel; +import java.awt.Color; +import javax.swing.SwingConstants; +import javax.swing.JTextField; +import javax.swing.JPanel; +import javax.swing.JLayeredPane; +import javax.swing.JComboBox; +import javax.swing.border.CompoundBorder; + +import java.awt.Color; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; +import javax.swing.border.TitledBorder; + +public class User { + + JFrame frame; + private JTextField txtSearchbookgo; + private JTextField txtTrip; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + User window = new User(); + window.frame.setVisible(true); + window.frame.setLocationRelativeTo(null); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public User() { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize() { + frame = new JFrame(); + frame.getContentPane().setBackground(Color.WHITE); + frame.setBounds(100, 100, 975, 520); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().setLayout(null); + + JButton btnNewButton = new JButton("Train"); + btnNewButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Train1 t=new Train1(); + //txtuser.setText(""); + t.Train1_frame.setVisible(true); + t.Train1_frame.setLocationRelativeTo(null); + } + }); + btnNewButton.setFont(new Font("Segoe Print", Font.PLAIN, 15)); + ImageIcon train = new ImageIcon(this.getClass().getResource("train.png")); + btnNewButton.setIcon(train); + btnNewButton.setBounds(141, 11, 129, 55); + frame.getContentPane().add(btnNewButton); + + JButton btnNewButton_1 = new JButton("Buses"); + btnNewButton_1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Bus1 b=new Bus1(); + //txtuser.setText(""); + b.Bus1_frame.setVisible(true); + b.Bus1_frame.setLocationRelativeTo(null); + } + }); + ImageIcon buses = new ImageIcon(this.getClass().getResource("buses.png")); + btnNewButton_1.setIcon(buses); + btnNewButton_1.setFont(new Font("Segoe Print", Font.PLAIN, 15)); + btnNewButton_1.setBounds(272, 11, 123, 55); + frame.getContentPane().add(btnNewButton_1); + + JButton btnNewButton_2 = new JButton("Hotels"); + btnNewButton_2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + } + }); + ImageIcon hotels = new ImageIcon(this.getClass().getResource("hotels.png")); + btnNewButton_2.setIcon(hotels); + btnNewButton_2.setFont(new Font("Segoe Print", Font.PLAIN, 15)); + btnNewButton_2.setBounds(433, 11, 138, 55); + frame.getContentPane().add(btnNewButton_2); + + JLabel lblNewLabel_1 = new JLabel(""); + lblNewLabel_1.setForeground(Color.BLACK); + ImageIcon banner = new ImageIcon(this.getClass().getResource("bus.png")); + lblNewLabel_1.setIcon(banner); + lblNewLabel_1.setOpaque(false); + lblNewLabel_1.setBounds(240, 136, 96, 76); + frame.getContentPane().add(lblNewLabel_1); + + txtSearchbookgo = new JTextField(); + txtSearchbookgo.setBorder(null); + txtSearchbookgo.setForeground(Color.WHITE); + txtSearchbookgo.setFont(new Font("Segoe Print", Font.BOLD, 30)); + txtSearchbookgo.setText("search . book . go"); + txtSearchbookgo.setOpaque(false); + //txtSearchbookgo.setVisible(true); + txtSearchbookgo.setBounds(318, 145, 311, 55); + frame.getContentPane().add(txtSearchbookgo); + txtSearchbookgo.setColumns(10); + + JLabel lblNewLabel = new JLabel(""); + ImageIcon scene1 = new ImageIcon(this.getClass().getResource("main (1).jpg")); + lblNewLabel.setIcon(scene1); + lblNewLabel.setBounds(0, 66, 960, 353); + frame.getContentPane().add(lblNewLabel); + ImageIcon login = new ImageIcon(this.getClass().getResource("login.png")); + + JButton btnNewButton_5 = new JButton("About Us"); + btnNewButton_5.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + AboutUs a=new AboutUs(); + a.Aboutus_frame.setVisible(true); + a.Aboutus_frame.setLocationRelativeTo(null); + } + }); + btnNewButton_5.setFont(new Font("Segoe Print", Font.PLAIN, 20)); + btnNewButton_5.setHorizontalAlignment(SwingConstants.LEFT); + btnNewButton_5.setBounds(0, 419, 960, 34); + frame.getContentPane().add(btnNewButton_5); + + JButton btnNewButton_6 = new JButton("Places To Visit"); + btnNewButton_6.setHorizontalAlignment(SwingConstants.LEFT); + btnNewButton_6.setFont(new Font("Segoe Print", Font.PLAIN, 20)); + btnNewButton_6.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + PlacesToVisit skySlideshow = new PlacesToVisit(); + skySlideshow.setVisible(true); + skySlideshow.setLocationRelativeTo(null); + } + }); + btnNewButton_6.setBounds(0, 453, 960, 34); + frame.getContentPane().add(btnNewButton_6); + + JButton btnNewButton_7 = new JButton("Help"); + btnNewButton_7.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Help h=new Help(); + h.Help_frame.setVisible(true); + h.Help_frame.setLocationRelativeTo(null); + } + }); + btnNewButton_7.setFont(new Font("Segoe Print", Font.PLAIN, 15)); + btnNewButton_7.setBounds(870, 11, 90, 55); + frame.getContentPane().add(btnNewButton_7); + + txtTrip = new JTextField(); + txtTrip.setBorder(null); + txtTrip.setForeground(Color.RED); + txtTrip.setFont(new Font("Rage Italic", Font.PLAIN, 36)); + txtTrip.setText("GoTravel"); + txtTrip.setBounds(10, 10, 138, 53); + frame.getContentPane().add(txtTrip); + txtTrip.setColumns(10); + + JButton btnNewButton_7_1 = new JButton("Contact Us"); + btnNewButton_7_1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ContactUs c=new ContactUs(); + c.frame.setVisible(true); + c.frame.setLocationRelativeTo(null); + + } + }); + btnNewButton_7_1.setFont(new Font("Segoe Print", Font.PLAIN, 15)); + btnNewButton_7_1.setBounds(731, 11, 138, 55); + frame.getContentPane().add(btnNewButton_7_1); + + + + + + + + + } +} diff --git a/Userr.java b/Userr.java new file mode 100644 index 0000000..e312180 --- /dev/null +++ b/Userr.java @@ -0,0 +1,567 @@ +//package Travel; +// +//import java.util.*; +//public class User { +// int choice1; +// String startLocation; +// String destination; +// String route; +// static City check_sLocation = null; +// static City check_destination = null; +// Scanner scn = new Scanner(System.in); +// Graph graph = new Graph(true,true,true,true,true,true,true); +// +// public void userLogin() { +// System.out.println(graph.cities.size()); +// System.out.println("YOU ARE LOGGED IN AS USER"); +// System.out.println("1.MAKE A TRIP"); +// System.out.println("2.SHOW PREVIOUS TRIPS"); +// System.out.print("\nENTER YOUR CHOICE: "); +// choice1 = scn.nextInt(); +// +// switch(choice1) { +// case 1: +// makeTrip(); +// tripPath(); +// break; +// case 2: +// prevTrip(); +// break; +// } +// } +// +// public void makeTrip() { +// int choice; +//// City check_sLocation = null; +//// City check_destination = null; +// String check_route; +// System.out.print("\nENTER START LOCATION: "); +// startLocation = scn.next(); +// check_sLocation=checkCity(startLocation); +// if(check_sLocation!=null) { +// System.out.print("\nENTER DESTINATION: "); +// destination = scn.next(); +// check_destination=checkDestination(destination); +// if(check_destination!=null) { +// System.out.print("\nENTER ROUTE (BUS/TRAIN): "); +// route = scn.next(); +// if(route.equalsIgnoreCase("bus") || route.equalsIgnoreCase("train")) { +// System.out.println("\nYOU HAVE BOOKED FOR "+route.toUpperCase()+"!!"); +// } +// while(!route.equalsIgnoreCase("bus") && !route.equalsIgnoreCase("train")) { +// System.out.print("\nINVALID ROUTE SELECTED!!\nENTER VAILD ROUTE (BUS/TRAIN) OR TO EXIT TYPE EXIT: "); +// route = scn.next(); +// if(route.equalsIgnoreCase("exit")) { +// System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); +// break; +// } +// else if(route.equalsIgnoreCase("bus") || route.equalsIgnoreCase("train")) { +// System.out.println("\nYOU HAVE BOOKED FOR "+route.toUpperCase()+"!!"); +// } +// } +// } +// } +// } +// public City checkCity(String city) { +// City checksLocation=null; +// checksLocation = graph.getCityByValue(city); +// int choice=0; +// while(checksLocation==null) { +// System.out.println("\nCITY NOT PRESENT"); +// System.out.print("STILL WANT TO CONTINUE???\nPRESS 1 FOR EXIT: "); +// choice = scn.nextInt(); +// if(choice!=1) { +// System.out.print("\nENTER START LOCATION: "); +// city = scn.next(); +// checksLocation = graph.getCityByValue(city +// ); +// } +// else { +// System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); +// break; +// } +// +// } +// return checksLocation; +// } +// public City checkDestination(String city) { +// City checksLocation=null; +// checksLocation = graph.getCityByValue(city); +// int choice=0; +// while(checksLocation==null) { +// System.out.println("\nCITY NOT PRESENT"); +// System.out.print("STILL WANT TO CONTINUE???\nPRESS 1 FOR EXIT: "); +// choice = scn.nextInt(); +// if(choice!=1) { +// System.out.print("\nENTER DESTINATION: "); +// city = scn.next(); +// checksLocation = graph.getCityByValue(city); +// } +// else { +// System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); +// break; +// } +// +// } +// return checksLocation; +// } +// +//public void prevTrip(){ +// +// } +// public void tripPath() { +// +// Dijikstra dj =new Dijikstra(); +// dj.dijikstraResultPrinter(dj.dijikstra(graph,check_sLocation)); +// dj.shortestPathBetween(graph,check_sLocation,check_destination); +// } +// +// +//} + + + + + +package Travel; + +import java.util.*; +class Trip{ + String date[]; + String name[]; + int age[]; + String gender[]; + int phNo[]; + //Linked List to store shortest route of booked trip + String storedTrip[]; + //LinkedList inside LLtrip to store shortest routes of booked trips + int n; +// int j=0; + Trip(String date[],String name[],int age[],String gender[],int phNo[],String storedTrip[]){ + this.date = date; + this.name = name; + this.age = age; + this.gender = gender; + this.phNo = phNo; + this.storedTrip = storedTrip; + } +} +public class Userr { + int num; + int j=0; + int choice1; + int y=0; + static int routeType; + String str=null; + //Bus1 bb=new Bus1(); + String startLocation; + String destination; + String route; + static City check_sLocation = null; + static City check_destination = null; + Scanner scn = new Scanner(System.in); + Graph graph = new Graph(true,true,true,true,true,true,true); + Trip trip=new Trip(null,null,null,null,null,null); + LinkedList LLTrip = new LinkedList(); + public void userLogin() { + System.out.println(graph.cities.size()); + System.out.println("YOU ARE LOGGED IN AS USER"); + System.out.println("1.MAKE A TRIP"); + System.out.println("2.SHOW PREVIOUS TRIPS"); + System.out.print("\nENTER YOUR CHOICE: "); + choice1 = scn.nextInt(); + + switch(choice1) { + case 1: + makeTrip(); + tripPath(); + break; + case 2: + prevTrip(); + break; + } + } + + public void makeTrip() { + int choice; +// City check_sLocation = null; +// City check_destination = null; +// int y=0; + String check_route; +// System.out.print("\nENTER START LOCATION: "); + //bb.startLocation = scn.next(); + check_sLocation=checkCity(startLocation); + if(check_sLocation!=null) { + //System.out.print("\nENTER DESTINATION: "); + //bb.destination = scn.next(); + check_destination=checkDestination(destination); + if(check_destination!=null) { + System.out.print("\nENTER ROUTE (BUS/TRAIN): "); + route = scn.next(); + + if(route.equalsIgnoreCase("bus") ) { + + System.out.println("\nYOU HAVE BOOKED FOR "+route.toUpperCase()+"!!"); + //int routeType; + System.out.print("ROUTETYPES: \nPress 1 for Shortest Distance 2 for Cheapest Cost and 3 for Least Time"); + routeType=scn.nextInt(); + if(routeType==1) { + y=1; + } + else if(routeType==2) { + y=2; + } + else if(routeType==3) { + y=3; + } + while(routeType!=1&&routeType!=2&&routeType!=3) { + System.out.println("YOU HAVE PROVIDED INVALID ROUTETYPE TO ENTER AGAIN PRESS 1 ELSE PRESS 0: "); + int enter=scn.nextInt(); + if(enter==1) { + System.out.print("ENTER VALID ROUTETYPE: "); + routeType=scn.nextInt(); + if(routeType==1) { + y=1; + } + else if(routeType==2) { + y=2; + } + else if(routeType==3) { + y=3; + } + } + else { + System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); + break; + } + } + } + else if(route.equalsIgnoreCase("train")) { + System.out.println("\nYOU HAVE BOOKED FOR "+route.toUpperCase()+"!!"); + //int routeType; + System.out.print("ROUTETYPES: \nPress 1 for Shortest Distance 2 for Cheapest Cost and 3 for Least Time"); + routeType=scn.nextInt(); + if(routeType!=1||routeType!=2||routeType!=3) { + y=1; + } + if(routeType==1) { + y=4; + } + else if(routeType==2) { + y=5; + } + else if(routeType==3) { + y=6; + } + while(routeType!=1&&routeType!=2&&routeType!=3) { + System.out.println("YOU HAVE PROVIDED INVALID ROUTETYPE TO ENTER AGAIN PRESS 1 ELSE PRESS 0: "); + int enter=scn.nextInt(); + if(enter==1) { + System.out.print("ENTER VALID ROUTETYPE: "); + routeType=scn.nextInt(); + if(routeType==1) { + y=4; + } + else if(routeType==2) { + y=5; + } + else if(routeType==3) { + y=6; + } + } + else { + System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); + break; + } + } + } + while(!route.equalsIgnoreCase("bus") && !route.equalsIgnoreCase("train")) { + System.out.print("\nINVALID ROUTE SELECTED!!\nENTER VAILD ROUTE (BUS/TRAIN) OR TO EXIT TYPE EXIT: "); + route = scn.next(); + if(route.equalsIgnoreCase("exit")) { + System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); + break; + } + else if(route.equalsIgnoreCase("bus")) { + System.out.println("\nYOU HAVE BOOKED FOR "+route.toUpperCase()+"!!"); + //int routeType; + System.out.print("ROUTETYPES: \nPress 1 for Shortest Distance 2 for Cheapest Cost and 3 for Least Time"); + routeType=scn.nextInt(); + if(routeType==1) { + y=1; + } + else if(routeType==2) { + y=2; + } + else if(routeType==3) { + y=3; + } + while(routeType!=1&&routeType!=2&&routeType!=3) { + System.out.println("YOU HAVE PROVIDED INVALID ROUTETYPE TO ENTER AGAIN PRESS 1 ELSE PRESS 0: "); + int enter=scn.nextInt(); + if(enter==1) { + System.out.print("ENTER VALID ROUTETYPE: "); + routeType=scn.nextInt(); + if(routeType==1) { + y=1; + } + else if(routeType==2) { + y=2; + } + else if(routeType==3) { + y=3; + } + } + else { + System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); + break; + } + } + } + else if(route.equalsIgnoreCase("train")) { + System.out.println("\nYOU HAVE BOOKED FOR "+route.toUpperCase()+"!!"); + //int routeType; + System.out.print("ROUTETYPES: \nPress 1 for Shortest Distance 2 for Cheapest Cost and 3 for Least Time"); + routeType=scn.nextInt(); + if(routeType==1) { + y=4; + } + else if(routeType==2) { + y=5; + } + else if(routeType==3) { + y=6; + } + while(routeType!=1&&routeType!=2&&routeType!=3) { + System.out.println("YOU HAVE PROVIDED INVALID ROUTETYPE TO ENTER AGAIN PRESS 1 ELSE PRESS 0: "); + int enter=scn.nextInt(); + if(enter==1) { + System.out.print("ENTER VALID ROUTETYPE: "); + routeType=scn.nextInt(); + if(routeType==1) { + y=4; + } + else if(routeType==2) { + y=5; + } + else if(routeType==3) { + y=6; + } + } + else { + System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); + break; + } + } + } + } + /// + } + } + } + public City checkCity(String city) { + City checksLocation=null; + checksLocation = graph.getCityByValue(city); + int choice=0; + while(checksLocation==null) { + System.out.println("\nCITY NOT PRESENT"); + System.out.print("STILL WANT TO CONTINUE???\nPRESS 1 FOR EXIT: "); + choice = scn.nextInt(); + if(choice!=1) { + System.out.print("\nENTER START LOCATION: "); + city = scn.next(); + checksLocation = graph.getCityByValue(city + ); + } + else { + System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); + break; + } + + } + return checksLocation; + } + public City checkDestination(String city) { + City checksLocation=null; + checksLocation = graph.getCityByValue(city); + int choice=0; + while(checksLocation==null) { + System.out.println("\nCITY NOT PRESENT"); + System.out.print("STILL WANT TO CONTINUE???\nPRESS 1 FOR EXIT: "); + choice = scn.nextInt(); + if(choice!=1) { + System.out.print("\nENTER DESTINATION: "); + city = scn.next(); + checksLocation = graph.getCityByValue(city); + } + else { + System.out.println("\nYOU HAVE QUIT SUCCESSFULLY!!!"); + break; + } + + } + return checksLocation; + } + + public void prevTrip(){ + //Saving booked trip + Trip info; + info = new Trip(trip.date,trip.name,trip.age,trip.gender,trip.phNo,trip.storedTrip); + LLTrip.add(j,info); + System.out.println("j"+j); +// System.out.println("path12"+LLTrip.get(j).storedTrip[0]+" "+LLTrip.get(j).storedTrip[1]); +// if(j==1) { +// System.out.println("path12 for j=0"+LLTrip.get(0).storedTrip[0]+" "+LLTrip.get(0).storedTrip[1]); +// } + j++; + +// System.out.println("path2"+LLTrip.get(1).storedTrip[0]+" "+LLTrip.get(1).storedTrip[1]); + + } + public void tripPath() { + if(y==1||y==2||y==3||y==4||y==5||y==6) { + Dijikstra dj =new Dijikstra(); + + dj.z=y; + System.out.println(y); + dj.dijikstraResultPrinter(dj.dijikstra(graph,check_sLocation)); + dj.shortestPathBetweennn(graph,check_sLocation,check_destination); + + + //System.out.println("path1"+trip.storedTrip[dj.r]); +// System.out.println("path2"+LLTrip.get(1).storedTrip[0]+" "+LLTrip.get(1).storedTrip[1]); + + + System.out.println("1. Do you want to book for this trip ?"); + System.out.println("2. Go back"); + System.out.println("Enter 1 to book"); + int book = scn.nextInt(); +//trip.storedTrip=new String[0]; + if(book==1) { + //Details of customer + + System.out.println("Enter the no. of passengers: "); + num = scn.nextInt(); + + trip.date = new String[num]; + trip.name=new String[num]; + trip.age=new int[num]; + trip.gender=new String[num]; + trip.phNo=new int[num]; + trip.storedTrip=new String[num]; + for(int i=0;i"); + System.out.println("\npath "+LLTrip.get(i).storedTrip[k]); + } +// for(j=0;j<2;j++) { +// System.out.println("\npath "+LLTrip.get(i).storedTrip[k]); +// } +// System.out.println("\n"); +// System.out.println("Path: "); +// for(int j=0;j"); +// } + //System.out.println("chat:"+String.join("->",trip.storedTrip)); + } +// for(int j=0;j