├── .idea ├── .name ├── vcs.xml ├── .gitignore ├── modules.xml ├── .idea │ ├── modules.xml │ ├── .idea.iml │ └── workspace.xml ├── artifacts │ └── OOP_Project_jar.xml ├── misc.xml └── uiDesigner.xml ├── src ├── META-INF │ └── MANIFEST.MF ├── DisplayClass.java ├── FlightDistance.java ├── RolesAndPermissions.java ├── RandomGenerator.java ├── Flight.java ├── Customer.java ├── FlightReservation.java └── User.java ├── out ├── production │ └── OOP-Project │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ ├── User.class │ │ ├── Flight.class │ │ ├── Customer.class │ │ ├── DisplayClass.class │ │ ├── FlightDistance.class │ │ ├── RandomGenerator.class │ │ ├── FlightReservation.class │ │ └── RolesAndPermissions.class └── artifacts │ └── OOP_Project_jar │ └── OOP-Project.jar ├── AirLineReservationSystemUML.pdf ├── OOP-Project.iml ├── LICENSE └── README.md /.idea/.name: -------------------------------------------------------------------------------- 1 | AirLineManagementSystem -------------------------------------------------------------------------------- /src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: User 3 | 4 | -------------------------------------------------------------------------------- /out/production/OOP-Project/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: User 3 | 4 | -------------------------------------------------------------------------------- /AirLineReservationSystemUML.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/AirLineReservationSystemUML.pdf -------------------------------------------------------------------------------- /out/production/OOP-Project/User.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/out/production/OOP-Project/User.class -------------------------------------------------------------------------------- /out/production/OOP-Project/Flight.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/out/production/OOP-Project/Flight.class -------------------------------------------------------------------------------- /out/production/OOP-Project/Customer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/out/production/OOP-Project/Customer.class -------------------------------------------------------------------------------- /out/artifacts/OOP_Project_jar/OOP-Project.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/out/artifacts/OOP_Project_jar/OOP-Project.jar -------------------------------------------------------------------------------- /out/production/OOP-Project/DisplayClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/out/production/OOP-Project/DisplayClass.class -------------------------------------------------------------------------------- /out/production/OOP-Project/FlightDistance.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/out/production/OOP-Project/FlightDistance.class -------------------------------------------------------------------------------- /out/production/OOP-Project/RandomGenerator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/out/production/OOP-Project/RandomGenerator.class -------------------------------------------------------------------------------- /out/production/OOP-Project/FlightReservation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/out/production/OOP-Project/FlightReservation.class -------------------------------------------------------------------------------- /out/production/OOP-Project/RolesAndPermissions.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recluzegeek/AirLineReservationSystem/HEAD/out/production/OOP-Project/RolesAndPermissions.class -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea/.idea.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/artifacts/OOP_Project_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/OOP_Project_jar 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/DisplayClass.java: -------------------------------------------------------------------------------- 1 | import java.util.List; 2 | 3 | public interface DisplayClass { 4 | 5 | void displayRegisteredUsersForAllFlight(); 6 | 7 | void displayRegisteredUsersForASpecificFlight(String flightNum); 8 | 9 | void displayHeaderForUsers(Flight flight, List c); 10 | 11 | void displayFlightsRegisteredByOneUser(String userID); 12 | 13 | void displayArtWork(int options); 14 | } 15 | -------------------------------------------------------------------------------- /OOP-Project.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Muhammad Salmanc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/FlightDistance.java: -------------------------------------------------------------------------------- 1 | public abstract class FlightDistance { 2 | public abstract String toString(int i); 3 | 4 | public abstract String[] calculateDistance(double lat1, double lon1, double lat2, double lon2); 5 | 6 | public void displayMeasurementInstructions(){ 7 | String symbols = "+---------------------------+"; 8 | System.out.printf("\n\n %100s\n %100s", symbols, "| SOME IMPORTANT GUIDELINES |"); 9 | System.out.printf("\n %100s\n", symbols); 10 | System.out.println("\n\t\t1. Distance between the destinations are based upon the Airports Coordinates(Latitudes && Longitudes) based in those cities\n"); 11 | System.out.println("\t\t2. Actual Distance of the flight may vary from this approximation as Airlines may define their on Travel Policy that may restrict the planes to fly through specific regions...\n"); 12 | System.out.println("\t\t3. Flight Time depends upon several factors such as Ground Speed(GS), AirCraft Design, Flight Altitude and Weather. Ground Speed for these calculations is 450 Knots...\n"); 13 | System.out.println("\t\t4. Expect reaching your destination early or late from the Arrival Time. So, please keep a margin of ±1 hour...\n"); 14 | System.out.println("\t\t5. The departure time is the moment that your plane pushes back from the gate, not the time it takes off. The arrival time is the moment that your plane pulls into the gate, not the time\n\t\t it touches down on the runway...\n"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/RolesAndPermissions.java: -------------------------------------------------------------------------------- 1 | public class RolesAndPermissions extends User { 2 | // ************************************************************ Behaviours/Methods ************************************************************ 3 | 4 | /** 5 | * Checks if the admin with specified credentials is registered or not. 6 | * @param username of the imaginary admin 7 | * @param password of the imaginary admin 8 | * @return -1 if admin not found, else index of the admin in the array. 9 | */ 10 | public int isPrivilegedUserOrNot(String username, String password) { 11 | int isFound = -1; 12 | for (int i = 0; i < adminUserNameAndPassword.length; i++) { 13 | if (username.equals(adminUserNameAndPassword[i][0])) { 14 | if (password.equals(adminUserNameAndPassword[i][1])) { 15 | isFound = i; 16 | break; 17 | } 18 | } 19 | } 20 | return isFound; 21 | } 22 | 23 | /** 24 | * Checks if the passenger with specified credentials is registered or not. 25 | * @param email of the specified passenger 26 | * @param password of the specified passenger 27 | * @return 1 with the userID if the passenger is registered, else 0 28 | */ 29 | public String isPassengerRegistered(String email, String password) { 30 | String isFound = "0"; 31 | for (Customer c : Customer.customerCollection) { 32 | if (email.equals(c.getEmail())) { 33 | if (password.equals(c.getPassword())) { 34 | isFound = "1-" + c.getUserID(); 35 | break; 36 | } 37 | } 38 | } 39 | return isFound; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.idea/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 1647687519187 26 | 32 | 33 | 34 | 35 | 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Requirements 2 | #### a. Java 15 or higher required to run .jar file of this project 3 | #### b. Intellij IDEA / Any Preferred IDE 4 | 5 | # AirLineReservationSystem 6 | A Java-based airline reservation system that uses Object-Oriented Programming. The system can manage customers, admins, flight booking and cancellation. 7 | It also includes many other features implemented in Java using OOP concepts like inheritance, encapsulation, association, and composition. 8 | ## ![image](https://user-images.githubusercontent.com/72850566/167471464-0afa5c6a-806d-4a62-97d4-947e73cd92d2.png) 9 | # Features 10 | The reservation system demonstrates the role of both the admin and the passenger. The admin sets up and manages the reservation system, while passengers use it to make reservations. 11 | ## 1. Customer Registration 12 | In order to get started with the program, you need to register first. Make sure you remember your login information, as you will need it to sign in. 13 | Registration screen can be seen in the image below: 14 | ## ![image](https://user-images.githubusercontent.com/72850566/167473655-96610ecf-5282-490c-b9e6-fd152d38fe54.png) 15 | ## 2. Customer Login 16 | You can access all the features of the program by logging in with your credentials. After successful login, you can avail all the features offered by the program. 17 | ## ![image](https://user-images.githubusercontent.com/72850566/167475733-d9a5e04c-32f7-4886-9dc7-ef7926c95ce6.png) 18 | ### a. Book Flight 19 | This module helps customers book a flight. Customers must enter the flight number and the number of tickets for the flight in order to make a reservation. An example is shown in the image below: 20 | ## ![image](https://user-images.githubusercontent.com/72850566/167619984-0b2241fb-ffc9-41bf-945a-4a8985718a49.png) 21 | ### b. Update Data 22 | This section allows users to modify their bio-data. Data includes name, email, phone number, address and age. 23 | If the user edits his data, logouts eventually and tries to log in with the old email, he won't be able to log in as his old email has been replaced. 24 | ## ![image](https://user-images.githubusercontent.com/72850566/167482100-9178c0ce-a134-4923-9da3-ff1b607d19d6.png) 25 | ### c. Delete Account 26 | If a user decides to delete their account, they can do so and all the data related to the account will be deleted. However, any flights that were registered by the user before they deleted their account will still be in the records. 27 | ## ![image](https://user-images.githubusercontent.com/72850566/167483584-aa68d166-0ce9-4a5e-a624-c94b0eb9497b.png) 28 | ### d. Random Flight Schedule 29 | This segment of the program shows the scheduled flights for this instance. The schedule may change as the program runs again. The number of flights in the schedule can be adjusted by adjusting the value of the **numOfFlights** variable in the **Flight class's flightScheduler()** method. 30 | ## ![image](https://user-images.githubusercontent.com/72850566/167483853-cb853ae5-09b6-46e2-a005-cd77ec60fa53.png) 31 | ### e. Cancel Flight 32 | Users can cancel a registered flight by specifying the number of tickets to cancel. These tickets will then be returned to the main flight scheduler. 33 | ### f. Flights Registered By Customer 34 | This section displays info about the flights registered by the logged in customer and also shows the flight status. Flights status updates as a scheduled flight is cancelled/deleted by the admin. 35 | ## ![image](https://user-images.githubusercontent.com/72850566/167658720-ef611cf2-d3b6-4d31-bb36-ca8bb789853a.png) 36 | ## 3. Admin Registration & Login 37 | The administration bears a heavy responsibility as they've to manage the entire system. An admin can perform **CRUD operations**, manage flights and customers. Following are the responsibilities of the admin for this reservation system. 38 | ## ![image](https://user-images.githubusercontent.com/72850566/167669614-fe53d361-9e05-4693-9631-856bd873204e.png) 39 | ### a. CRUD Operations 40 | 41 | ### b. Delete a Flight 42 | ### c. Display All Passengers 43 | ### d. Display All Flights Registered By a Passenger 44 | ### e. Display All Registered Passengers In a Flight 45 | -------------------------------------------------------------------------------- /src/RandomGenerator.java: -------------------------------------------------------------------------------- 1 | import java.util.Random; 2 | 3 | public class RandomGenerator { 4 | 5 | // ************************************************************ Fields ************************************************************ 6 | 7 | private String randomNum; 8 | /* City name is at the 0-index, its latitude is on the 1-index and longitude on the 2-index*/ 9 | private static final String[][] destinations = { 10 | {"Karachi", "24.871940", "66.988060"}, {"Bangkok", "13.921430", "100.595337"}, {"Jakarta", "-6.174760", "106.827072"}, 11 | {"Islamabad", "33.607587", "73.100316"}, {"New York City", "40.642422", "-73.781749"}, {"Lahore", "31.521139", "74.406519"}, 12 | {"Gilgit Baltistan", "35.919108", "74.332838"}, {"Jeddah", "21.683647", "39.152862"}, {"Riyadh", "24.977080", "46.688942"}, {"New Delhi", "28.555764", "77.096520"}, 13 | {"Hong Kong", "22.285005", "114.158339"}, {"Beijing", "40.052121", "116.609609"}, {"Tokyo", "35.550899", "139.780683"}, {"Kuala Lumpur", "2.749914", "101.707160"}, 14 | {"Sydney", "-33.942028", "151.174304"}, {"Melbourne", "-37.671812", "144.846079"}, {"Cape Town", "-33.968879", "18.596982"}, {"Madrid", "40.476938", "-3.569428"}, 15 | {"Dublin", "53.424077", "-6.256792"}, {"Johannesburg", "25.936834", "27.925890"}, {"London", "51.504473", "0.052271"}, {"Los Angeles", "33.942912", "-118.406829"}, 16 | {"Brisbane", "-27.388925", "153.116751"}, {"Amsterdam", "52.308100", "4.764170"}, {"Stockholm", "59.651236", "17.924793"}, {"Frankfurt", "50.050085", "8.571911"}, 17 | {"New Taipei City", "25.066471", "121.551638"}, {"Rio de Janeiro", "-22.812160", "-43.248636"}, {"Seoul", "37.558773", "126.802822"}, {"Yokohama", "35.462819", "139.637008"}, 18 | {"Ankara", "39.951898", "32.688792"}, {"Casablanca", "33.368202", "-7.580998"}, {"Shenzhen", "22.633977", "113.809360"}, {"Baghdad", "33.264824", "44.232014"}, 19 | {"Alexandria", "40.232302", "-85.637150"}, {"Pune", "18.579019", "73.908572"}, {"Shanghai", "31.145326", "121.804512"}, {"Istanbul", "41.289143", "41.261401", "28.742376"}, 20 | {"Bhutan", "22.648322", "88.443152"}, {"Dhaka", "23.847177", "90.404133"}, {"Munich", "48.354327", "11.788680"}, {"Perth", "56.435749", "-3.371675"}, 21 | {"Mexico", "21.038103", "-86.875259"}, {"California", "32.733089", "-117.194514"}, {"Kabul", "34.564296", "69.211574"}, {"Yangon", "47.604505", "-122.330604"}, 22 | {"Lagos", "17.981829", "102.565684"}, {"Santiago", "-33.394795", "-70.790183"}, {"Kuwait", "29.239250", "47.971575"}, {"Nairobi", "39.958361", "41.174310"}, 23 | {"Tehran", "35.696000", "51.401000"}, {"Saint Petersburg", "60.013492", "29.722189"}, {"Hanoi", "21.219185", "105.803967"}, {"Sialkot", "32.328361", "74.215310"}, 24 | {"Berlin", "52.554316", "13.291213"}, {"Paris", "48.999560", "2.539274"}, {"Dubai", "25.249869", "55.366483"} 25 | }; 26 | 27 | // ************************************************************ Behaviours/Methods ************************************************************ 28 | 29 | 30 | /* Generates Random ID for the Customers....*/ 31 | public void randomIDGen() { 32 | Random rand = new Random(); 33 | String randomID = Integer.toString(rand.nextInt(1000000)); 34 | 35 | while (Integer.parseInt(randomID) < 20000) { 36 | randomID = Integer.toString(rand.nextInt(1000000)); 37 | } 38 | setRandomNum(randomID); 39 | } 40 | 41 | /*This method sets the destinations for each of the flights from the above destinations randomly.....*/ 42 | public String[][] randomDestinations() { 43 | Random rand = new Random(); 44 | int randomCity1 = rand.nextInt(destinations.length); 45 | int randomCity2 = rand.nextInt(destinations.length); 46 | String fromWhichCity = destinations[randomCity1][0]; 47 | String fromWhichCityLat = destinations[randomCity1][1]; 48 | String fromWhichCityLong = destinations[randomCity1][2]; 49 | while (randomCity2 == randomCity1) { 50 | randomCity2 = rand.nextInt(destinations.length); 51 | } 52 | String toWhichCity = destinations[randomCity2][0]; 53 | String toWhichCityLat = destinations[randomCity2][1]; 54 | String toWhichCityLong = destinations[randomCity2][2]; 55 | String[][] chosenDestinations = new String[2][3]; 56 | chosenDestinations[0][0] = fromWhichCity; 57 | chosenDestinations[0][1] = fromWhichCityLat; 58 | chosenDestinations[0][2] = fromWhichCityLong; 59 | chosenDestinations[1][0] = toWhichCity; 60 | chosenDestinations[1][1] = toWhichCityLat; 61 | chosenDestinations[1][2] = toWhichCityLong; 62 | return chosenDestinations; 63 | } 64 | 65 | /*Generates the Random Number of Seats for each flight*/ 66 | public int randomNumOfSeats() { 67 | Random random = new Random(); 68 | int numOfSeats = random.nextInt(500); 69 | while (numOfSeats < 75) { 70 | numOfSeats = random.nextInt(500); 71 | } 72 | return numOfSeats; 73 | } 74 | 75 | /*Generates the Unique Flight Number....*/ 76 | public String randomFlightNumbGen(int uptoHowManyLettersRequired, int divisible) { 77 | Random random = new Random(); 78 | StringBuilder randomAlphabets = new StringBuilder(); 79 | for (int i = 0; i < uptoHowManyLettersRequired; i++) { 80 | randomAlphabets.append((char) (random.nextInt(26) + 'a')); 81 | } 82 | randomAlphabets.append("-").append(randomNumOfSeats() / divisible); 83 | return randomAlphabets.toString(); 84 | } 85 | 86 | // ************************************************************ Setters & Getters ************************************************************ 87 | 88 | public void setRandomNum(String randomNum) { 89 | this.randomNum = randomNum; 90 | } 91 | 92 | public String getRandomNumber() { 93 | return randomNum; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /src/Flight.java: -------------------------------------------------------------------------------- 1 | import java.time.Instant; 2 | import java.time.LocalDateTime; 3 | import java.time.ZoneId; 4 | import java.time.format.DateTimeFormatter; 5 | import java.time.temporal.ChronoUnit; 6 | import java.util.*; 7 | 8 | public class Flight extends FlightDistance { 9 | 10 | // ************************************************************ Fields ************************************************************ 11 | 12 | private final String flightSchedule; 13 | private final String flightNumber; 14 | private final String fromWhichCity; 15 | private final String gate; 16 | private final String toWhichCity; 17 | private double distanceInMiles; 18 | private double distanceInKm; 19 | private String flightTime; 20 | private int numOfSeatsInTheFlight; 21 | private List listOfRegisteredCustomersInAFlight; 22 | private int customerIndex; 23 | private static int nextFlightDay = 0; 24 | private static final List flightList = new ArrayList<>(); 25 | 26 | // ************************************************************ Behaviours/Methods ************************************************************ 27 | 28 | Flight() { 29 | this.flightSchedule = null; 30 | this.flightNumber = null; 31 | this.numOfSeatsInTheFlight = 0; 32 | toWhichCity = null; 33 | fromWhichCity = null; 34 | this.gate = null; 35 | } 36 | 37 | /** 38 | * Creates new random flight from the specified arguments. 39 | * 40 | * @param flightSchedule includes departure date and time of flight 41 | * @param flightNumber unique identifier of each flight 42 | * @param numOfSeatsInTheFlight available seats in the flight 43 | * @param chosenDestinations consists of origin and destination airports(cities) 44 | * @param distanceBetweenTheCities gives the distance between the airports both in miles and kilometers 45 | * @param gate from where passengers will board to the aircraft 46 | */ 47 | Flight(String flightSchedule, String flightNumber, int numOfSeatsInTheFlight, String[][] chosenDestinations, String[] distanceBetweenTheCities, String gate) { 48 | this.flightSchedule = flightSchedule; 49 | this.flightNumber = flightNumber; 50 | this.numOfSeatsInTheFlight = numOfSeatsInTheFlight; 51 | this.fromWhichCity = chosenDestinations[0][0]; 52 | this.toWhichCity = chosenDestinations[1][0]; 53 | this.distanceInMiles = Double.parseDouble(distanceBetweenTheCities[0]); 54 | this.distanceInKm = Double.parseDouble(distanceBetweenTheCities[1]); 55 | this.flightTime = calculateFlightTime(distanceInMiles); 56 | this.listOfRegisteredCustomersInAFlight = new ArrayList<>(); 57 | this.gate = gate; 58 | } 59 | 60 | /** 61 | * Creates Flight Schedule. All methods of this class are collaborating with each other 62 | * to create flight schedule of the said length in this method. 63 | */ 64 | public void flightScheduler() { 65 | int numOfFlights = 15; // decides how many unique flights to be included/display in scheduler 66 | RandomGenerator r1 = new RandomGenerator(); 67 | for (int i = 0; i < numOfFlights; i++) { 68 | String[][] chosenDestinations = r1.randomDestinations(); 69 | String[] distanceBetweenTheCities = calculateDistance(Double.parseDouble(chosenDestinations[0][1]), Double.parseDouble(chosenDestinations[0][2]), Double.parseDouble(chosenDestinations[1][1]), Double.parseDouble(chosenDestinations[1][2])); 70 | String flightSchedule = createNewFlightsAndTime(); 71 | String flightNumber = r1.randomFlightNumbGen(2, 1).toUpperCase(); 72 | int numOfSeatsInTheFlight = r1.randomNumOfSeats(); 73 | String gate = r1.randomFlightNumbGen(1, 30); 74 | flightList.add(new Flight(flightSchedule, flightNumber, numOfSeatsInTheFlight, chosenDestinations, distanceBetweenTheCities, gate.toUpperCase())); 75 | } 76 | } 77 | 78 | /** 79 | * Registers new Customer in this Flight. 80 | * 81 | * @param customer customer to be registered 82 | */ 83 | void addNewCustomerToFlight(Customer customer) { 84 | this.listOfRegisteredCustomersInAFlight.add(customer); 85 | } 86 | 87 | /** 88 | * Adds numOfTickets to existing customer's tickets for the this flight. 89 | * 90 | * @param customer customer in which tickets are to be added 91 | * @param numOfTickets number of tickets to add 92 | */ 93 | void addTicketsToExistingCustomer(Customer customer, int numOfTickets) { 94 | customer.addExistingFlightToCustomerList(customerIndex, numOfTickets); 95 | } 96 | 97 | /*** 98 | * Checks if the specified customer is already registered in the FLight's array list 99 | * @param customersList of the flight 100 | * @param customer specified customer to be checked 101 | * @return true if the customer is already registered in the said flight, false otherwise 102 | */ 103 | boolean isCustomerAlreadyAdded(List customersList, Customer customer) { 104 | boolean isAdded = false; 105 | for (Customer customer1 : customersList) { 106 | if (customer1.getUserID().equals(customer.getUserID())) { 107 | isAdded = true; 108 | customerIndex = customersList.indexOf(customer1); 109 | break; 110 | } 111 | } 112 | return isAdded; 113 | } 114 | 115 | /** 116 | * Calculates the flight time, using avg. ground speed of 450 knots. 117 | * 118 | * @param distanceBetweenTheCities distance between the cities/airports in miles 119 | * @return formatted flight time 120 | */ 121 | public String calculateFlightTime(double distanceBetweenTheCities) { 122 | double groundSpeed = 450; 123 | double time = (distanceBetweenTheCities / groundSpeed); 124 | String timeInString = String.format("%.4s", time); 125 | String[] timeArray = timeInString.replace('.', ':').split(":"); 126 | int hours = Integer.parseInt(timeArray[0]); 127 | int minutes = Integer.parseInt(timeArray[1]); 128 | int modulus = minutes % 5; 129 | // Changing flight time to make minutes near/divisible to 5. 130 | if (modulus < 3) { 131 | minutes -= modulus; 132 | } else { 133 | minutes += 5 - modulus; 134 | } 135 | if (minutes >= 60) { 136 | minutes -= 60; 137 | hours++; 138 | } 139 | if (hours <= 9 && Integer.toString(minutes).length() == 1) { 140 | return String.format("0%s:%s0", hours, minutes); 141 | } else if (hours <= 9 && Integer.toString(minutes).length() > 1) { 142 | return String.format("0%s:%s", hours, minutes); 143 | } else if (hours > 9 && Integer.toString(minutes).length() == 1) { 144 | return String.format("%s:%s0", hours, minutes); 145 | } else { 146 | return String.format("%s:%s", hours, minutes); 147 | } 148 | } 149 | 150 | /** 151 | * Creates flight arrival time by adding flight time to flight departure time 152 | * 153 | * @return flight arrival time 154 | */ 155 | public String fetchArrivalTime() { 156 | /*These lines convert the String of flightSchedule to LocalDateTIme and add the arrivalTime to it....*/ 157 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEEE, dd MMMM yyyy, HH:mm a "); 158 | LocalDateTime departureDateTime = LocalDateTime.parse(flightSchedule, formatter); 159 | 160 | /*Getting the Flight Time, plane was in air*/ 161 | String[] flightTime = getFlightTime().split(":"); 162 | int hours = Integer.parseInt(flightTime[0]); 163 | int minutes = Integer.parseInt(flightTime[1]); 164 | 165 | 166 | LocalDateTime arrivalTime; 167 | 168 | arrivalTime = departureDateTime.plusHours(hours).plusMinutes(minutes); 169 | DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("EE, dd-MM-yyyy HH:mm a"); 170 | return arrivalTime.format(formatter1); 171 | 172 | } 173 | 174 | void deleteFlight(String flightNumber) { 175 | boolean isFound = false; 176 | Iterator list = flightList.iterator(); 177 | while (list.hasNext()) { 178 | Flight flight = list.next(); 179 | if (flight.getFlightNumber().equalsIgnoreCase(flightNumber)) { 180 | isFound = true; 181 | break; 182 | } 183 | } 184 | if (isFound) { 185 | list.remove(); 186 | } else { 187 | System.out.println("Flight with given Number not found..."); 188 | } 189 | displayFlightSchedule(); 190 | } 191 | 192 | /** 193 | * Calculates the distance between the cities/airports based on their lat longs. 194 | * 195 | * @param lat1 origin city/airport latitude 196 | * @param lon1 origin city/airport longitude 197 | * @param lat2 destination city/airport latitude 198 | * @param lon2 destination city/airport longitude 199 | * @return distance both in miles and km between the cities/airports 200 | */ 201 | @Override 202 | public String[] calculateDistance(double lat1, double lon1, double lat2, double lon2) { 203 | double theta = lon1 - lon2; 204 | double distance = Math.sin(degreeToRadian(lat1)) * Math.sin(degreeToRadian(lat2)) + Math.cos(degreeToRadian(lat1)) * Math.cos(degreeToRadian(lat2)) * Math.cos(degreeToRadian(theta)); 205 | distance = Math.acos(distance); 206 | distance = radianToDegree(distance); 207 | distance = distance * 60 * 1.1515; 208 | /* On the Zero-Index, distance will be in Miles, on 1st-index, distance will be in KM and on the 2nd index distance will be in KNOTS*/ 209 | String[] distanceString = new String[3]; 210 | distanceString[0] = String.format("%.2f", distance * 0.8684); 211 | distanceString[1] = String.format("%.2f", distance * 1.609344); 212 | distanceString[2] = Double.toString(Math.round(distance * 100.0) / 100.0); 213 | return distanceString; 214 | } 215 | 216 | private double degreeToRadian(double deg) { 217 | return (deg * Math.PI / 180.0); 218 | } 219 | 220 | private double radianToDegree(double rad) { 221 | return (rad * 180.0 / Math.PI); 222 | } 223 | 224 | public void displayFlightSchedule() { 225 | 226 | Iterator flightIterator = flightList.iterator(); 227 | System.out.println(); 228 | System.out.print("+------+-------------------------------------------+-----------+------------------+-----------------------+------------------------+---------------------------+-------------+--------+------------------------+\n"); 229 | System.out.printf("| Num | FLIGHT SCHEDULE\t\t\t | FLIGHT NO | Available Seats | \tFROM ====>> | \t====>> TO\t | \t ARRIVAL TIME | FLIGHT TIME | GATE | DISTANCE(MILES/KMS) |%n"); 230 | System.out.print("+------+-------------------------------------------+-----------+------------------+-----------------------+------------------------+---------------------------+-------------+--------+------------------------+\n"); 231 | int i = 0; 232 | while (flightIterator.hasNext()) { 233 | i++; 234 | Flight f1 = flightIterator.next(); 235 | System.out.println(f1.toString(i)); 236 | System.out.print("+------+-------------------------------------------+-----------+------------------+-----------------------+------------------------+---------------------------+-------------+--------+------------------------+\n"); 237 | } 238 | } 239 | 240 | @Override 241 | public String toString(int i) { 242 | return String.format("| %-5d| %-41s | %-9s | \t%-9s | %-21s | %-22s | %-10s | %-6sHrs | %-4s | %-8s / %-11s|", i, flightSchedule, flightNumber, numOfSeatsInTheFlight, fromWhichCity, toWhichCity, fetchArrivalTime(), flightTime, gate, distanceInMiles, distanceInKm); 243 | } 244 | 245 | /** 246 | * Creates new random flight schedule 247 | * 248 | * @return newly created flight schedule 249 | */ 250 | public String createNewFlightsAndTime() { 251 | 252 | Calendar c = Calendar.getInstance(); 253 | // Incrementing nextFlightDay, so that next scheduled flight would be in the future, not in the present 254 | nextFlightDay += Math.random() * 7; 255 | c.add(Calendar.DATE, nextFlightDay); 256 | c.add(Calendar.HOUR, nextFlightDay); 257 | c.set(Calendar.MINUTE, ((c.get(Calendar.MINUTE) * 3) - (int) (Math.random() * 45))); 258 | Date myDateObj = c.getTime(); 259 | LocalDateTime date = Instant.ofEpochMilli(myDateObj.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime(); 260 | date = getNearestHourQuarter(date); 261 | return date.format(DateTimeFormatter.ofPattern("EEEE, dd MMMM yyyy, HH:mm a ")); 262 | } 263 | 264 | /** 265 | * Formats flight schedule, so that the minutes would be to the nearest quarter. 266 | * 267 | * @param datetime to be formatting 268 | * @return formatted LocalDateTime with minutes close to the nearest hour quarter 269 | */ 270 | public LocalDateTime getNearestHourQuarter(LocalDateTime datetime) { 271 | int minutes = datetime.getMinute(); 272 | int mod = minutes % 15; 273 | LocalDateTime newDatetime; 274 | if (mod < 8) { 275 | newDatetime = datetime.minusMinutes(mod); 276 | } else { 277 | newDatetime = datetime.plusMinutes(15 - mod); 278 | } 279 | newDatetime = newDatetime.truncatedTo(ChronoUnit.MINUTES); 280 | return newDatetime; 281 | } 282 | 283 | 284 | // ************************************************************ Setters & Getters ************************************************************ 285 | 286 | public int getNoOfSeats() { 287 | return numOfSeatsInTheFlight; 288 | } 289 | 290 | public String getFlightNumber() { 291 | return flightNumber; 292 | } 293 | 294 | public void setNoOfSeatsInTheFlight(int numOfSeatsInTheFlight) { 295 | this.numOfSeatsInTheFlight = numOfSeatsInTheFlight; 296 | } 297 | 298 | public String getFlightTime() { 299 | return flightTime; 300 | } 301 | 302 | public List getFlightList() { 303 | return flightList; 304 | } 305 | 306 | public List getListOfRegisteredCustomersInAFlight() { 307 | return listOfRegisteredCustomersInAFlight; 308 | } 309 | 310 | public String getFlightSchedule() { 311 | return flightSchedule; 312 | } 313 | 314 | public String getFromWhichCity() { 315 | return fromWhichCity; 316 | } 317 | 318 | public String getGate() { 319 | return gate; 320 | } 321 | 322 | public String getToWhichCity() { 323 | return toWhichCity; 324 | } 325 | 326 | } -------------------------------------------------------------------------------- /src/Customer.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Customer { 4 | 5 | // ************************************************************ Fields ************************************************************ 6 | private final String userID; 7 | private String email; 8 | private String name; 9 | private String phone; 10 | private final String password; 11 | private String address; 12 | private int age; 13 | public List flightsRegisteredByUser; 14 | public List numOfTicketsBookedByUser; 15 | public static final List customerCollection = User.getCustomersCollection(); 16 | 17 | // ************************************************************ Behaviours/Methods ************************************************************ 18 | 19 | 20 | Customer() { 21 | this.userID = null; 22 | this.name = null; 23 | this.email = null; 24 | this.password = null; 25 | this.phone = null; 26 | this.address = null; 27 | this.age = 0; 28 | } 29 | 30 | /** 31 | * Registers new customer to the program. Obj of RandomGenerator(Composition) is 32 | * being used to assign unique userID to the newly created customer. 33 | * 34 | * @param name name of the customer 35 | * @param email customer's email 36 | * @param password customer's account password 37 | * @param phone customer's phone-number 38 | * @param address customer's address 39 | * @param age customer's age 40 | */ 41 | Customer(String name, String email, String password, String phone, String address, int age) { 42 | RandomGenerator random = new RandomGenerator(); 43 | random.randomIDGen(); 44 | this.name = name; 45 | this.userID = random.getRandomNumber(); 46 | this.email = email; 47 | this.password = password; 48 | this.phone = phone; 49 | this.address = address; 50 | this.age = age; 51 | this.flightsRegisteredByUser = new ArrayList<>(); 52 | this.numOfTicketsBookedByUser = new ArrayList<>(); 53 | } 54 | 55 | /** 56 | * Takes input for the new customer and adds them to programs memory. isUniqueData() validates the entered email 57 | * and returns true if the entered email is already registered. If email is already registered, program will ask the user 58 | * to enter new email address to get himself register. 59 | */ 60 | public void addNewCustomer() { 61 | System.out.printf("\n\n\n%60s ++++++++++++++ Welcome to the Customer Registration Portal ++++++++++++++", ""); 62 | Scanner read = new Scanner(System.in); 63 | System.out.print("\nEnter your name :\t"); 64 | String name = read.nextLine(); 65 | System.out.print("Enter your email address :\t"); 66 | String email = read.nextLine(); 67 | while (isUniqueData(email)) { 68 | System.out.println("ERROR!!! User with the same email already exists... Use new email or login using the previous credentials...."); 69 | System.out.print("Enter your email address :\t"); 70 | email = read.nextLine(); 71 | } 72 | System.out.print("Enter your Password :\t"); 73 | String password = read.nextLine(); 74 | System.out.print("Enter your Phone number :\t"); 75 | String phone = read.nextLine(); 76 | System.out.print("Enter your address :\t"); 77 | String address = read.nextLine(); 78 | System.out.print("Enter your age :\t"); 79 | int age = read.nextInt(); 80 | customerCollection.add(new Customer(name, email, password, phone, address, age)); 81 | } 82 | 83 | /** 84 | * Returns String consisting of customers data(name, age, email etc...) for displaying. 85 | * randomIDDisplay() adds space between the userID for easy readability. 86 | * 87 | * @param i for serial numbers. 88 | * @return customers data in String 89 | */ 90 | private String toString(int i) { 91 | return String.format("%10s| %-10d | %-10s | %-32s | %-7s | %-27s | %-35s | %-23s |", "", i, randomIDDisplay(userID), name, age, email, address, phone); 92 | } 93 | 94 | /** 95 | * Searches for customer with the given ID and displays the customers' data if found. 96 | * 97 | * @param ID of the searching/required customer 98 | */ 99 | public void searchUser(String ID) { 100 | boolean isFound = false; 101 | Customer customerWithTheID = customerCollection.get(0); 102 | for (Customer c : customerCollection) { 103 | if (ID.equals(c.getUserID())) { 104 | System.out.printf("%-50sCustomer Found...!!!Here is the Full Record...!!!\n\n\n", " "); 105 | displayHeader(); 106 | isFound = true; 107 | customerWithTheID = c; 108 | break; 109 | } 110 | } 111 | if (isFound) { 112 | System.out.println(customerWithTheID.toString(1)); 113 | System.out.printf("%10s+------------+------------+----------------------------------+---------+-----------------------------+-------------------------------------+-------------------------+\n", ""); 114 | } else { 115 | System.out.printf("%-50sNo Customer with the ID %s Found...!!!\n", " ", ID); 116 | } 117 | } 118 | 119 | /** 120 | * Returns true if the given emailID is already registered, false otherwise 121 | * 122 | * @param emailID to be checked in the list 123 | */ 124 | public boolean isUniqueData(String emailID) { 125 | boolean isUnique = false; 126 | for (Customer c : customerCollection) { 127 | if (emailID.equals(c.getEmail())) { 128 | isUnique = true; 129 | break; 130 | } 131 | } 132 | return isUnique; 133 | } 134 | 135 | public void editUserInfo(String ID) { 136 | boolean isFound = false; 137 | Scanner read = new Scanner(System.in); 138 | for (Customer c : customerCollection) { 139 | if (ID.equals(c.getUserID())) { 140 | isFound = true; 141 | System.out.print("\nEnter the new name of the Passenger:\t"); 142 | String name = read.nextLine(); 143 | c.setName(name); 144 | System.out.print("Enter the new email address of Passenger " + name + ":\t"); 145 | c.setEmail(read.nextLine()); 146 | System.out.print("Enter the new Phone number of Passenger " + name + ":\t"); 147 | c.setPhone(read.nextLine()); 148 | System.out.print("Enter the new address of Passenger " + name + ":\t"); 149 | c.setAddress(read.nextLine()); 150 | System.out.print("Enter the new age of Passenger " + name + ":\t"); 151 | c.setAge(read.nextInt()); 152 | displayCustomersData(false); 153 | break; 154 | } 155 | } 156 | if (!isFound) { 157 | System.out.printf("%-50sNo Customer with the ID %s Found...!!!\n", " ", ID); 158 | } 159 | } 160 | 161 | public void deleteUser(String ID) { 162 | boolean isFound = false; 163 | Iterator iterator = customerCollection.iterator(); 164 | while (iterator.hasNext()) { 165 | Customer customer = iterator.next(); 166 | if (ID.equals(customer.getUserID())) { 167 | isFound = true; 168 | break; 169 | } 170 | } 171 | if (isFound) { 172 | iterator.remove(); 173 | System.out.printf("\n%-50sPrinting all Customer's Data after deleting Customer with the ID %s.....!!!!\n", "", ID); 174 | displayCustomersData(false); 175 | } else { 176 | System.out.printf("%-50sNo Customer with the ID %s Found...!!!\n", " ", ID); 177 | } 178 | } 179 | 180 | /** 181 | * Shows the customers' data in formatted way. 182 | * @param showHeader to check if we want to print ascii art for the customers' data. 183 | */ 184 | public void displayCustomersData(boolean showHeader) { 185 | if (showHeader) { 186 | displayArtWork(3); 187 | } 188 | displayHeader(); 189 | Iterator iterator = customerCollection.iterator(); 190 | int i = 0; 191 | while (iterator.hasNext()) { 192 | i++; 193 | Customer c = iterator.next(); 194 | System.out.println(c.toString(i)); 195 | System.out.printf("%10s+------------+------------+----------------------------------+---------+-----------------------------+-------------------------------------+-------------------------+\n", ""); 196 | } 197 | } 198 | 199 | /** 200 | * Shows the header for printing customers data 201 | */ 202 | void displayHeader() { 203 | System.out.println(); 204 | System.out.printf("%10s+------------+------------+----------------------------------+---------+-----------------------------+-------------------------------------+-------------------------+\n", ""); 205 | System.out.printf("%10s| SerialNum | UserID | Passenger Names | Age | EmailID\t\t | Home Address\t\t\t | Phone Number\t |%n", ""); 206 | System.out.printf("%10s+------------+------------+----------------------------------+---------+-----------------------------+-------------------------------------+-------------------------+\n", ""); 207 | System.out.println(); 208 | 209 | } 210 | 211 | /** 212 | * Adds space between userID to increase its readability 213 | *

214 | * Example: 215 | *

216 | * "920 191" is much more readable than "920191" 217 | * 218 | * @param randomID id to add space 219 | * @return randomID with added space 220 | */ 221 | String randomIDDisplay(String randomID) { 222 | StringBuilder newString = new StringBuilder(); 223 | for (int i = 0; i <= randomID.length(); i++) { 224 | if (i == 3) { 225 | newString.append(" ").append(randomID.charAt(i)); 226 | } else if (i < randomID.length()) { 227 | newString.append(randomID.charAt(i)); 228 | } 229 | } 230 | return newString.toString(); 231 | } 232 | 233 | /** 234 | * Associates a new flight with the specified customer 235 | * 236 | * @param f flight to associate 237 | */ 238 | void addNewFlightToCustomerList(Flight f) { 239 | this.flightsRegisteredByUser.add(f); 240 | // numOfFlights++; 241 | } 242 | 243 | /** 244 | * Adds numOfTickets to already booked flights 245 | * @param index at which flight is registered in the arraylist 246 | * @param numOfTickets how many tickets to add 247 | */ 248 | void addExistingFlightToCustomerList(int index, int numOfTickets) { 249 | int newNumOfTickets = numOfTicketsBookedByUser.get(index) + numOfTickets; 250 | this.numOfTicketsBookedByUser.set(index, newNumOfTickets); 251 | } 252 | 253 | /** 254 | * Prints out "ASCII Art" for the specified words. 255 | * 256 | * @param option specifies which word to print. 257 | */ 258 | void displayArtWork(int option) { 259 | String artWork = ""; 260 | if (option == 1) { 261 | artWork = """ 262 | 263 | d8b db d88888b db d8b db .o88b. db db .d8888. d888888b .d88b. .88b d88. d88888b d8888b.\s 264 | 888o 88 88' 88 I8I 88 d8P Y8 88 88 88' YP `~~88~~' .8P Y8. 88'YbdP`88 88' 88 `8D\s 265 | 88V8o 88 88ooooo 88 I8I 88 8P 88 88 `8bo. 88 88 88 88 88 88 88ooooo 88oobY'\s 266 | 88 V8o88 88~~~~~ Y8 I8I 88 8b 88 88 `Y8b. 88 88 88 88 88 88 88~~~~~ 88`8b \s 267 | 88 V888 88. `8b d8'8b d8' Y8b d8 88b d88 db 8D 88 `8b d8' 88 88 88 88. 88 `88.\s 268 | VP V8P Y88888P `8b8' `8d8' `Y88P' ~Y8888P' `8888Y' YP `Y88P' YP YP YP Y88888P 88 YD\s 269 | \s 270 | \s 271 | """; 272 | } else if (option == 2) { 273 | artWork = """ 274 | 275 | .d8888. d88888b .d8b. d8888b. .o88b. db db .o88b. db db .d8888. d888888b .d88b. .88b d88. d88888b d8888b.\s 276 | 88' YP 88' d8' `8b 88 `8D d8P Y8 88 88 d8P Y8 88 88 88' YP `~~88~~' .8P Y8. 88'YbdP`88 88' 88 `8D\s 277 | `8bo. 88ooooo 88ooo88 88oobY' 8P 88ooo88 8P 88 88 `8bo. 88 88 88 88 88 88 88ooooo 88oobY'\s 278 | `Y8b. 88~~~~~ 88~~~88 88`8b 8b 88~~~88 8b 88 88 `Y8b. 88 88 88 88 88 88 88~~~~~ 88`8b \s 279 | db 8D 88. 88 88 88 `88. Y8b d8 88 88 Y8b d8 88b d88 db 8D 88 `8b d8' 88 88 88 88. 88 `88.\s 280 | `8888Y' Y88888P YP YP 88 YD `Y88P' YP YP `Y88P' ~Y8888P' `8888Y' YP `Y88P' YP YP YP Y88888P 88 YD\s 281 | \s 282 | \s 283 | """; 284 | } else if (option == 3) { 285 | artWork = """ 286 | 287 | .d8888. db db .d88b. db d8b db d888888b d8b db d888b .d8b. db db d8888b. .d8b. .d8888. .d8888. d88888b d8b db d888b d88888b d8888b. .d8888.\s 288 | 88' YP 88 88 .8P Y8. 88 I8I 88 `88' 888o 88 88' Y8b d8' `8b 88 88 88 `8D d8' `8b 88' YP 88' YP 88' 888o 88 88' Y8b 88' 88 `8D 88' YP\s 289 | `8bo. 88ooo88 88 88 88 I8I 88 88 88V8o 88 88 88ooo88 88 88 88oodD' 88ooo88 `8bo. `8bo. 88ooooo 88V8o 88 88 88ooooo 88oobY' `8bo. \s 290 | `Y8b. 88~~~88 88 88 Y8 I8I 88 88 88 V8o88 88 ooo 88~~~88 88 88 88~~~ 88~~~88 `Y8b. `Y8b. 88~~~~~ 88 V8o88 88 ooo 88~~~~~ 88`8b `Y8b.\s 291 | db 8D 88 88 `8b d8' `8b d8'8b d8' .88. 88 V888 88. ~8~ 88 88 88booo. 88booo. 88 88 88 db 8D db 8D 88. 88 V888 88. ~8~ 88. 88 `88. db 8D\s 292 | `8888Y' YP YP `Y88P' `8b8' `8d8' Y888888P VP V8P Y888P YP YP Y88888P Y88888P 88 YP YP `8888Y' `8888Y' Y88888P VP V8P Y888P Y88888P 88 YD `8888Y'\s 293 | \s 294 | \s 295 | """; 296 | } else if (option == 4) { 297 | artWork = """ 298 | 299 | d8888b. d88888b d888b d888888b .d8888. d888888b d88888b d8888b. d88888b d8888b. d8888b. .d8b. .d8888. .d8888. d88888b d8b db d888b d88888b d8888b. .d8888. \s 300 | 88 `8D 88' 88' Y8b `88' 88' YP `~~88~~' 88' 88 `8D 88' 88 `8D 88 `8D d8' `8b 88' YP 88' YP 88' 888o 88 88' Y8b 88' 88 `8D 88' YP \s 301 | 88oobY' 88ooooo 88 88 `8bo. 88 88ooooo 88oobY' 88ooooo 88 88 88oodD' 88ooo88 `8bo. `8bo. 88ooooo 88V8o 88 88 88ooooo 88oobY' `8bo. \s 302 | 88`8b 88~~~~~ 88 ooo 88 `Y8b. 88 88~~~~~ 88`8b 88~~~~~ 88 88 88~~~ 88~~~88 `Y8b. `Y8b. 88~~~~~ 88 V8o88 88 ooo 88~~~~~ 88`8b `Y8b. \s 303 | 88 `88. 88. 88. ~8~ .88. db 8D 88 88. 88 `88. 88. 88 .8D 88 88 88 db 8D db 8D 88. 88 V888 88. ~8~ 88. 88 `88. db 8D \s 304 | 88 YD Y88888P Y888P Y888888P `8888Y' YP Y88888P 88 YD Y88888P Y8888D' 88 YP YP `8888Y' `8888Y' Y88888P VP V8P Y888P Y88888P 88 YD `8888Y' \s 305 | 306 | \s 307 | d888888b d8b db d88888b db d888888b d888b db db d888888b \s 308 | `88' 888o 88 88' 88 `88' 88' Y8b 88 88 `~~88~~' \s 309 | 88 88V8o 88 88ooo 88 88 88 88ooo88 88 \s 310 | 88 88 V8o88 88~~~ 88 88 88 ooo 88~~~88 88 \s 311 | .88. 88 V888 88 88booo. .88. 88. ~8~ 88 88 88 \s 312 | Y888888P VP V8P YP Y88888P Y888888P Y888P YP YP YP \s 313 | \s 314 | \s 315 | """; 316 | } else if (option == 5) { 317 | artWork = """ 318 | 319 | d8888b. d88888b db d88888b d888888b d88888b d88888b db d888888b d888b db db d888888b\s 320 | 88 `8D 88' 88 88' `~~88~~' 88' 88' 88 `88' 88' Y8b 88 88 `~~88~~'\s 321 | 88 88 88ooooo 88 88ooooo 88 88ooooo 88ooo 88 88 88 88ooo88 88 \s 322 | 88 88 88~~~~~ 88 88~~~~~ 88 88~~~~~ 88~~~ 88 88 88 ooo 88~~~88 88 \s 323 | 88 .8D 88. 88booo. 88. 88 88. 88 88booo. .88. 88. ~8~ 88 88 88 \s 324 | Y8888D' Y88888P Y88888P Y88888P YP Y88888P YP Y88888P Y888888P Y888P YP YP YP \s 325 | \s 326 | \s 327 | """; 328 | } 329 | System.out.println(artWork); 330 | } 331 | 332 | // ************************************************************ Setters & Getters ************************************************************ 333 | 334 | public List getFlightsRegisteredByUser() { 335 | return flightsRegisteredByUser; 336 | } 337 | 338 | public String getPassword() { 339 | return password; 340 | } 341 | 342 | public String getPhone() { 343 | return phone; 344 | } 345 | 346 | public String getAddress() { 347 | return address; 348 | } 349 | 350 | public String getEmail() { 351 | return email; 352 | } 353 | 354 | public int getAge() { 355 | return age; 356 | } 357 | 358 | public String getUserID() { 359 | return userID; 360 | } 361 | 362 | public String getName() { 363 | return name; 364 | } 365 | 366 | public List getNumOfTicketsBookedByUser() { 367 | return numOfTicketsBookedByUser; 368 | } 369 | 370 | public void setName(String name) { 371 | this.name = name; 372 | } 373 | 374 | public void setEmail(String email) { 375 | this.email = email; 376 | } 377 | 378 | public void setPhone(String phone) { 379 | this.phone = phone; 380 | } 381 | 382 | public void setAddress(String address) { 383 | this.address = address; 384 | } 385 | 386 | public void setAge(int age) { 387 | this.age = age; 388 | } 389 | } -------------------------------------------------------------------------------- /src/FlightReservation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * FlightReservation class allows the user to book, cancel and check the status of the registered flights. 3 | * 4 | * 5 | * */ 6 | 7 | 8 | import java.util.Iterator; 9 | import java.util.List; 10 | import java.util.Scanner; 11 | 12 | public class FlightReservation implements DisplayClass { 13 | 14 | // ************************************************************ Fields ************************************************************ 15 | Flight flight = new Flight(); 16 | int flightIndexInFlightList; 17 | 18 | // ************************************************************ Behaviours/Methods ************************************************************ 19 | 20 | 21 | /** 22 | * Book the numOfTickets for said flight for the specified user. Update the available seats in main system by 23 | * Subtracting the numOfTickets from the main system. If a new customer registers for the flight, then it adds 24 | * the customer to that flight, else if the user is already added to that flight, then it just updates the 25 | * numOfSeats of that flight. 26 | * 27 | * @param flightNo FlightID of the flight to be booked 28 | * @param numOfTickets number of tickets to be booked 29 | * @param userID userID of the user which is booking the flight 30 | */ 31 | void bookFlight(String flightNo, int numOfTickets, String userID) { 32 | boolean isFound = false; 33 | for (Flight f1 : flight.getFlightList()) { 34 | if (flightNo.equalsIgnoreCase(f1.getFlightNumber())) { 35 | for (Customer customer : Customer.customerCollection) { 36 | if (userID.equals(customer.getUserID())) { 37 | isFound = true; 38 | f1.setNoOfSeatsInTheFlight(f1.getNoOfSeats() - numOfTickets); 39 | if (!f1.isCustomerAlreadyAdded(f1.getListOfRegisteredCustomersInAFlight(), customer)) { 40 | f1.addNewCustomerToFlight(customer); 41 | } 42 | if (isFlightAlreadyAddedToCustomerList(customer.flightsRegisteredByUser, f1)) { 43 | addNumberOfTicketsToAlreadyBookedFlight(customer, numOfTickets); 44 | if (flightIndex(flight.getFlightList(), flight) != -1) { 45 | customer.addExistingFlightToCustomerList(flightIndex(flight.getFlightList(), flight), numOfTickets); 46 | } 47 | } else { 48 | customer.addNewFlightToCustomerList(f1); 49 | addNumberOfTicketsForNewFlight(customer, numOfTickets); 50 | } 51 | break; 52 | } 53 | } 54 | } 55 | } 56 | if (!isFound) { 57 | System.out.println("Invalid Flight Number...! No flight with the ID \"" + flightNo + "\" was found..."); 58 | } else { 59 | System.out.printf("\n %50s You've booked %d tickets for Flight \"%5s\"...", "", numOfTickets, flightNo.toUpperCase()); 60 | } 61 | } 62 | 63 | /** 64 | * Cancels the flight for a particular user and return/add the numOfTickets back to 65 | * the main flight scheduler. 66 | * 67 | * @param userID ID of the user for whom the flight is to be cancelled 68 | */ 69 | void cancelFlight(String userID) { 70 | String flightNum = ""; 71 | Scanner read = new Scanner(System.in); 72 | int index = 0, ticketsToBeReturned; 73 | boolean isFound = false; 74 | for (Customer customer : Customer.customerCollection) { 75 | if (userID.equals(customer.getUserID())) { 76 | if (customer.getFlightsRegisteredByUser().size() != 0) { 77 | System.out.printf("%50s %s Here is the list of all the Flights registered by you %s", " ", "++++++++++++++", "++++++++++++++"); 78 | displayFlightsRegisteredByOneUser(userID); 79 | System.out.print("Enter the Flight Number of the Flight you want to cancel : "); 80 | flightNum = read.nextLine(); 81 | System.out.print("Enter the number of tickets to cancel : "); 82 | int numOfTickets = read.nextInt(); 83 | Iterator flightIterator = customer.getFlightsRegisteredByUser().iterator(); 84 | while (flightIterator.hasNext()) { 85 | Flight flight = flightIterator.next(); 86 | if (flightNum.equalsIgnoreCase(flight.getFlightNumber())) { 87 | isFound = true; 88 | int numOfTicketsForFlight = customer.getNumOfTicketsBookedByUser().get(index); 89 | while (numOfTickets > numOfTicketsForFlight) { 90 | System.out.print("ERROR!!! Number of tickets cannot be greater than " + numOfTicketsForFlight + " for this flight. Please enter the number of tickets again : "); 91 | numOfTickets = read.nextInt(); 92 | } 93 | if (numOfTicketsForFlight == numOfTickets) { 94 | ticketsToBeReturned = flight.getNoOfSeats() + numOfTicketsForFlight; 95 | customer.numOfTicketsBookedByUser.remove(index); 96 | flightIterator.remove(); 97 | } else { 98 | ticketsToBeReturned = numOfTickets + flight.getNoOfSeats(); 99 | customer.numOfTicketsBookedByUser.set(index, (numOfTicketsForFlight - numOfTickets)); 100 | } 101 | flight.setNoOfSeatsInTheFlight(ticketsToBeReturned); 102 | break; 103 | } 104 | index++; 105 | } 106 | 107 | }else{ 108 | System.out.println("No Flight Has been Registered by you with ID \"\"" + flightNum.toUpperCase() +"\"\"....."); 109 | } 110 | // index++; 111 | if (!isFound) { 112 | System.out.println("ERROR!!! Couldn't find Flight with ID \"" + flightNum.toUpperCase() + "\"....."); 113 | } 114 | } 115 | } 116 | } 117 | 118 | void addNumberOfTicketsToAlreadyBookedFlight(Customer customer, int numOfTickets) { 119 | int newNumOfTickets = customer.numOfTicketsBookedByUser.get(flightIndexInFlightList) + numOfTickets; 120 | customer.numOfTicketsBookedByUser.set(flightIndexInFlightList, newNumOfTickets); 121 | } 122 | 123 | void addNumberOfTicketsForNewFlight(Customer customer, int numOfTickets) { 124 | customer.numOfTicketsBookedByUser.add(numOfTickets); 125 | } 126 | 127 | boolean isFlightAlreadyAddedToCustomerList(List flightList, Flight flight) { 128 | boolean addedOrNot = false; 129 | for (Flight flight1 : flightList) { 130 | if (flight1.getFlightNumber().equalsIgnoreCase(flight.getFlightNumber())) { 131 | this.flightIndexInFlightList = flightList.indexOf(flight1); 132 | addedOrNot = true; 133 | break; 134 | } 135 | } 136 | return addedOrNot; 137 | } 138 | 139 | String flightStatus(Flight flight) { 140 | boolean isFlightAvailable = false; 141 | for (Flight list : flight.getFlightList()) { 142 | if (list.getFlightNumber().equalsIgnoreCase(flight.getFlightNumber())) { 143 | isFlightAvailable = true; 144 | break; 145 | } 146 | } 147 | if (isFlightAvailable) { 148 | return "As Per Schedule"; 149 | } else { 150 | return " Cancelled "; 151 | } 152 | } 153 | 154 | /*toString() Method for displaying number of flights registered by single user...*/ 155 | public String toString(int serialNum, Flight flights, Customer customer) { 156 | return String.format("| %-5d| %-41s | %-9s | \t%-9d | %-21s | %-22s | %-10s | %-6sHrs | %-4s | %-10s |", serialNum, flights.getFlightSchedule(), flights.getFlightNumber(), customer.numOfTicketsBookedByUser.get(serialNum - 1), flights.getFromWhichCity(), flights.getToWhichCity(), flights.fetchArrivalTime(), flights.getFlightTime(), flights.getGate(), flightStatus(flights)); 157 | } 158 | 159 | @Override 160 | public void displayFlightsRegisteredByOneUser(String userID) { 161 | System.out.println(); 162 | System.out.print("+------+-------------------------------------------+-----------+------------------+-----------------------+------------------------+---------------------------+-------------+--------+-----------------+\n"); 163 | System.out.printf("| Num | FLIGHT SCHEDULE\t\t\t | FLIGHT NO | Booked Tickets | \tFROM ====>> | \t====>> TO\t | \t ARRIVAL TIME | FLIGHT TIME | GATE | FLIGHT STATUS |%n"); 164 | System.out.print("+------+-------------------------------------------+-----------+------------------+-----------------------+------------------------+---------------------------+-------------+--------+-----------------+\n"); 165 | for (Customer customer : Customer.customerCollection) { 166 | List f = customer.getFlightsRegisteredByUser(); 167 | int size = customer.getFlightsRegisteredByUser().size(); 168 | if (userID.equals(customer.getUserID())) { 169 | for (int i = 0; i < size; i++) { 170 | System.out.println(toString((i + 1), f.get(i), customer)); 171 | System.out.print("+------+-------------------------------------------+-----------+------------------+-----------------------+------------------------+---------------------------+-------------+--------+-----------------+\n"); 172 | } 173 | } 174 | } 175 | } 176 | 177 | /*overloaded toString() method for displaying all users in a flight....*/ 178 | 179 | public String toString(int serialNum, Customer customer, int index) { 180 | return String.format("%10s| %-10d | %-10s | %-32s | %-7s | %-27s | %-35s | %-23s | %-7s |", "", (serialNum + 1), customer.randomIDDisplay(customer.getUserID()), customer.getName(), 181 | customer.getAge(), customer.getEmail(), customer.getAddress(), customer.getPhone(), customer.numOfTicketsBookedByUser.get(index)); 182 | } 183 | 184 | @Override 185 | public void displayHeaderForUsers(Flight flight, List c) { 186 | System.out.printf("\n%65s Displaying Registered Customers for Flight No. \"%-6s\" %s \n\n", "+++++++++++++", flight.getFlightNumber(), "+++++++++++++"); 187 | System.out.printf("%10s+------------+------------+----------------------------------+---------+-----------------------------+-------------------------------------+-------------------------+----------------+\n", ""); 188 | System.out.printf("%10s| SerialNum | UserID | Passenger Names | Age | EmailID\t\t | Home Address\t\t\t | Phone Number\t | Booked Tickets |%n", ""); 189 | System.out.printf("%10s+------------+------------+----------------------------------+---------+-----------------------------+-------------------------------------+-------------------------+----------------+\n", ""); 190 | int size = flight.getListOfRegisteredCustomersInAFlight().size(); 191 | for (int i = 0; i < size; i++) { 192 | System.out.println(toString(i, c.get(i), flightIndex(c.get(i).flightsRegisteredByUser, flight))); 193 | System.out.printf("%10s+------------+------------+----------------------------------+---------+-----------------------------+-------------------------------------+-------------------------+----------------+\n", ""); 194 | } 195 | } 196 | 197 | @Override 198 | public void displayRegisteredUsersForAllFlight() { 199 | System.out.println(); 200 | for (Flight flight : flight.getFlightList()) { 201 | List c = flight.getListOfRegisteredCustomersInAFlight(); 202 | int size = flight.getListOfRegisteredCustomersInAFlight().size(); 203 | if (size != 0) { 204 | displayHeaderForUsers(flight, c); 205 | } 206 | } 207 | } 208 | 209 | int flightIndex(List flightList, Flight flight) { 210 | int i = -1; 211 | for (Flight flight1 : flightList) { 212 | if (flight1.equals(flight)) { 213 | i = flightList.indexOf(flight1); 214 | } 215 | } 216 | return i; 217 | } 218 | 219 | @Override 220 | public void displayRegisteredUsersForASpecificFlight(String flightNum) { 221 | System.out.println(); 222 | for (Flight flight : flight.getFlightList()) { 223 | List c = flight.getListOfRegisteredCustomersInAFlight(); 224 | if (flight.getFlightNumber().equalsIgnoreCase(flightNum)) { 225 | displayHeaderForUsers(flight, c); 226 | } 227 | } 228 | } 229 | 230 | @Override 231 | public void displayArtWork(int option) { 232 | String artWork; 233 | if (option == 1) { 234 | artWork = """ 235 | 236 | d8888b. .d88b. .d88b. db dD d88888b db d888888b d888b db db d888888b\s 237 | 88 `8D .8P Y8. .8P Y8. 88 ,8P' 88' 88 `88' 88' Y8b 88 88 `~~88~~'\s 238 | 88oooY' 88 88 88 88 88,8P 88ooo 88 88 88 88ooo88 88 \s 239 | 88~~~b. 88 88 88 88 88`8b 88~~~ 88 88 88 ooo 88~~~88 88 \s 240 | 88 8D `8b d8' `8b d8' 88 `88. 88 88booo. .88. 88. ~8~ 88 88 88 \s 241 | Y8888P' `Y88P' `Y88P' YP YD YP Y88888P Y888888P Y888P YP YP YP \s 242 | \s 243 | \s 244 | """; 245 | } else if (option == 2) { 246 | artWork = """ 247 | 248 | d88888b d8888b. d888888b d888888b d888888b d8b db d88888b .d88b. \s 249 | 88' 88 `8D `88' `~~88~~' `88' 888o 88 88' .8P Y8.\s 250 | 88ooooo 88 88 88 88 88 88V8o 88 88ooo 88 88\s 251 | 88~~~~~ 88 88 88 88 88 88 V8o88 88~~~ 88 88\s 252 | 88. 88 .8D .88. 88 .88. 88 V888 88 `8b d8'\s 253 | Y88888P Y8888D' Y888888P YP Y888888P VP V8P YP `Y88P' \s 254 | \s 255 | \s 256 | """; 257 | } else if (option == 3) { 258 | artWork = """ 259 | 260 | d8888b. d88888b db d88888b d888888b d88888b .d8b. .o88b. .o88b. .d88b. db db d8b db d888888b\s 261 | 88 `8D 88' 88 88' `~~88~~' 88' d8' `8b d8P Y8 d8P Y8 .8P Y8. 88 88 888o 88 `~~88~~'\s 262 | 88 88 88ooooo 88 88ooooo 88 88ooooo 88ooo88 8P 8P 88 88 88 88 88V8o 88 88 \s 263 | 88 88 88~~~~~ 88 88~~~~~ 88 88~~~~~ 88~~~88 8b 8b 88 88 88 88 88 V8o88 88 \s 264 | 88 .8D 88. 88booo. 88. 88 88. 88 88 Y8b d8 Y8b d8 `8b d8' 88b d88 88 V888 88 \s 265 | Y8888D' Y88888P Y88888P Y88888P YP Y88888P YP YP `Y88P' `Y88P' `Y88P' ~Y8888P' VP V8P YP \s 266 | \s 267 | \s 268 | """; 269 | } else if (option == 4) { 270 | artWork = """ 271 | 272 | d8888b. .d8b. d8b db d8888b. .d88b. .88b d88. d88888b db d888888b d888b db db d888888b .d8888. .o88b. db db d88888b d8888b. db db db d88888b\s 273 | 88 `8D d8' `8b 888o 88 88 `8D .8P Y8. 88'YbdP`88 88' 88 `88' 88' Y8b 88 88 `~~88~~' 88' YP d8P Y8 88 88 88' 88 `8D 88 88 88 88' \s 274 | 88oobY' 88ooo88 88V8o 88 88 88 88 88 88 88 88 88ooo 88 88 88 88ooo88 88 `8bo. 8P 88ooo88 88ooooo 88 88 88 88 88 88ooooo\s 275 | 88`8b 88~~~88 88 V8o88 88 88 88 88 88 88 88 88~~~ 88 88 88 ooo 88~~~88 88 `Y8b. 8b 88~~~88 88~~~~~ 88 88 88 88 88 88~~~~~\s 276 | 88 `88. 88 88 88 V888 88 .8D `8b d8' 88 88 88 88 88booo. .88. 88. ~8~ 88 88 88 db 8D Y8b d8 88 88 88. 88 .8D 88b d88 88booo. 88. \s 277 | 88 YD YP YP VP V8P Y8888D' `Y88P' YP YP YP YP Y88888P Y888888P Y888P YP YP YP `8888Y' `Y88P' YP YP Y88888P Y8888D' ~Y8888P' Y88888P Y88888P\s 278 | \s 279 | Are you thinking that it's not feasible(RandomSchedule)...Then you can confirm it by re-running the program... 280 | """; 281 | } else if (option == 5) { 282 | artWork = """ 283 | 284 | .o88b. .d8b. d8b db .o88b. d88888b db d88888b db d888888b d888b db db d888888b\s 285 | d8P Y8 d8' `8b 888o 88 d8P Y8 88' 88 88' 88 `88' 88' Y8b 88 88 `~~88~~'\s 286 | 8P 88ooo88 88V8o 88 8P 88ooooo 88 88ooo 88 88 88 88ooo88 88 \s 287 | 8b 88~~~88 88 V8o88 8b 88~~~~~ 88 88~~~ 88 88 88 ooo 88~~~88 88 \s 288 | Y8b d8 88 88 88 V888 Y8b d8 88. 88booo. 88 88booo. .88. 88. ~8~ 88 88 88 \s 289 | `Y88P' YP YP VP V8P `Y88P' Y88888P Y88888P YP Y88888P Y888888P Y888P YP YP YP \s 290 | \s 291 | \s 292 | """; 293 | } else if (option == 6) { 294 | artWork = """ 295 | 296 | d8888b. d88888b d888b d888888b .d8888. d888888b d88888b d8888b. d88888b d8888b. d88888b db d888888b d888b db db d888888b .d8888. \s 297 | 88 `8D 88' 88' Y8b `88' 88' YP `~~88~~' 88' 88 `8D 88' 88 `8D 88' 88 `88' 88' Y8b 88 88 `~~88~~' 88' YP \s 298 | 88oobY' 88ooooo 88 88 `8bo. 88 88ooooo 88oobY' 88ooooo 88 88 88ooo 88 88 88 88ooo88 88 `8bo. \s 299 | 88`8b 88~~~~~ 88 ooo 88 `Y8b. 88 88~~~~~ 88`8b 88~~~~~ 88 88 88~~~ 88 88 88 ooo 88~~~88 88 `Y8b. \s 300 | 88 `88. 88. 88. ~8~ .88. db 8D 88 88. 88 `88. 88. 88 .8D 88 88booo. .88. 88. ~8~ 88 88 88 db 8D \s 301 | 88 YD Y88888P Y888P Y888888P `8888Y' YP Y88888P 88 YD Y88888P Y8888D' YP Y88888P Y888888P Y888P YP YP YP `8888Y' \s 302 | \s 303 | \s 304 | d8888b. db db d8888b. .d8b. .d8888. .d8888. d88888b d8b db d888b d88888b d8888b. \s 305 | 88 `8D `8b d8' 88 `8D d8' `8b 88' YP 88' YP 88' 888o 88 88' Y8b 88' 88 `8D \s 306 | 88oooY' `8bd8' 88oodD' 88ooo88 `8bo. `8bo. 88ooooo 88V8o 88 88 88ooooo 88oobY' \s 307 | 88~~~b. 88 88~~~ 88~~~88 `Y8b. `Y8b. 88~~~~~ 88 V8o88 88 ooo 88~~~~~ 88`8b \s 308 | 88 8D 88 88 88 88 db 8D db 8D 88. 88 V888 88. ~8~ 88. 88 `88. \s 309 | Y8888P' YP 88 YP YP `8888Y' `8888Y' Y88888P VP V8P Y888P Y88888P 88 YD \s 310 | \s 311 | \s 312 | """; 313 | } else { 314 | artWork = """ 315 | 316 | db .d88b. d888b d888b d88888b d8888b. .d88b. db db d888888b\s 317 | 88 .8P Y8. 88' Y8b 88' Y8b 88' 88 `8D .8P Y8. 88 88 `~~88~~'\s 318 | 88 88 88 88 88 88ooooo 88 88 88 88 88 88 88 \s 319 | 88 88 88 88 ooo 88 ooo 88~~~~~ 88 88 88 88 88 88 88 \s 320 | 88booo. `8b d8' 88. ~8~ 88. ~8~ 88. 88 .8D `8b d8' 88b d88 88 \s 321 | Y88888P `Y88P' Y888P Y888P Y88888P Y8888D' `Y88P' ~Y8888P' YP \s 322 | \s 323 | \s 324 | """; 325 | } 326 | 327 | System.out.println(artWork); 328 | } 329 | } 330 | -------------------------------------------------------------------------------- /src/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is intended to be the main class for this Project. All necessary methods are getting calls from this class. 3 | * 4 | * 5 | */ 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Scanner; 10 | 11 | public class User { 12 | 13 | // ************************************************************ Fields ************************************************************ 14 | 15 | /*2D Array to store admin credentials. Default credentials are stored on [0][0] index. Max num of admins can be 10....*/ 16 | static String[][] adminUserNameAndPassword = new String[10][2]; 17 | private static List customersCollection = new ArrayList<>(); 18 | 19 | // ************************************************************ Behaviours/Methods ************************************************************ 20 | 21 | public static void main(String[] args) { 22 | int countNumOfUsers = 1; 23 | RolesAndPermissions r1 = new RolesAndPermissions(); 24 | Flight f1 = new Flight(); 25 | FlightReservation bookingAndReserving = new FlightReservation(); 26 | Customer c1 = new Customer(); 27 | f1.flightScheduler(); 28 | Scanner read = new Scanner(System.in); 29 | 30 | 31 | welcomeScreen(1); 32 | System.out.println("\n\t\t\t\t\t+++++++++++++ Welcome to BAV AirLines +++++++++++++\n\nTo Further Proceed, Please enter a value."); 33 | System.out.println("\n***** Default Username && Password is root-root ***** Using Default Credentials will restrict you to just view the list of Passengers....\n"); 34 | displayMainMenu(); 35 | int desiredOption = read.nextInt(); 36 | while (desiredOption < 0 || desiredOption > 8) { 37 | System.out.print("ERROR!! Please enter value between 0 - 4. Enter the value again :\t"); 38 | desiredOption = read.nextInt(); 39 | } 40 | 41 | 42 | do { 43 | Scanner read1 = new Scanner(System.in); 44 | /* If desiredOption is 1 then call the login method.... if default credentials are used then set the permission 45 | * level to standard/default where the user can just view the customer's data...if not found, then return -1, and if 46 | * data is found then show the user display menu for adding, updating, deleting and searching users/customers... 47 | * */ 48 | if (desiredOption == 1) { 49 | 50 | /*Default username and password....*/ 51 | adminUserNameAndPassword[0][0] = "root"; 52 | adminUserNameAndPassword[0][1] = "root"; 53 | printArtWork(1); 54 | System.out.print("\nEnter the UserName to login to the Management System : "); 55 | String username = read1.nextLine(); 56 | System.out.print("Enter the Password to login to the Management System : "); 57 | String password = read1.nextLine(); 58 | System.out.println(); 59 | 60 | /*Checking the RolesAndPermissions......*/ 61 | if (r1.isPrivilegedUserOrNot(username, password) == -1) { 62 | System.out.printf("\n%20sERROR!!! Unable to login Cannot find user with the entered credentials.... Try Creating New Credentials or get yourself register by pressing 4....\n", ""); 63 | } else if (r1.isPrivilegedUserOrNot(username, password) == 0) { 64 | System.out.println("You've standard/default privileges to access the data... You can just view customers data..." + "Can't perform any actions on them...."); 65 | c1.displayCustomersData(true); 66 | } else { 67 | System.out.printf("%-20sLogged in Successfully as \"%s\"..... For further Proceedings, enter a value from below....", "", username); 68 | 69 | /*Going to Display the CRUD operations to be performed by the privileged user.....Which includes Creating, Updating 70 | * Reading(Searching) and deleting a customer.... 71 | * */ 72 | do { 73 | System.out.printf("\n\n%-60s+++++++++ 2nd Layer Menu +++++++++%50sLogged in as \"%s\"\n", "", "", username); 74 | System.out.printf("%-30s (a) Enter 1 to add new Passenger....\n", ""); 75 | System.out.printf("%-30s (b) Enter 2 to search a Passenger....\n", ""); 76 | System.out.printf("%-30s (c) Enter 3 to update the Data of the Passenger....\n", ""); 77 | System.out.printf("%-30s (d) Enter 4 to delete a Passenger....\n", ""); 78 | System.out.printf("%-30s (e) Enter 5 to Display all Passengers....\n", ""); 79 | System.out.printf("%-30s (f) Enter 6 to Display all flights registered by a Passenger...\n", ""); 80 | System.out.printf("%-30s (g) Enter 7 to Display all registered Passengers in a Flight....\n", ""); 81 | System.out.printf("%-30s (h) Enter 8 to Delete a Flight....\n", ""); 82 | System.out.printf("%-30s (i) Enter 0 to Go back to the Main Menu/Logout....\n", ""); 83 | System.out.print("Enter the desired Choice : "); 84 | desiredOption = read.nextInt(); 85 | /*If 1 is entered by the privileged user, then add a new customer......*/ 86 | if (desiredOption == 1) { 87 | c1.displayArtWork(1); 88 | c1.addNewCustomer(); 89 | } else if (desiredOption == 2) { 90 | /*If 2 is entered by the privileged user, then call the search method of the Customer class*/ 91 | c1.displayArtWork(2); 92 | c1.displayCustomersData(false); 93 | System.out.print("Enter the CustomerID to Search :\t"); 94 | String customerID = read1.nextLine(); 95 | System.out.println(); 96 | c1.searchUser(customerID); 97 | } else if (desiredOption == 3) { 98 | /*If 3 is entered by the user, then call the update method of the Customer Class with required 99 | * arguments..... 100 | * */ 101 | bookingAndReserving.displayArtWork(2); 102 | c1.displayCustomersData(false); 103 | System.out.print("Enter the CustomerID to Update its Data :\t"); 104 | String customerID = read1.nextLine(); 105 | if (customersCollection.size() > 0) { 106 | c1.editUserInfo(customerID); 107 | } else { 108 | System.out.printf("%-50sNo Customer with the ID %s Found...!!!\n", " ", customerID); 109 | } 110 | 111 | } else if (desiredOption == 4) { 112 | /*If 4 is entered, then ask the user to enter the customer id, and then delete 113 | * that customer.... 114 | * */ 115 | bookingAndReserving.displayArtWork(3); 116 | c1.displayCustomersData(false); 117 | System.out.print("Enter the CustomerID to Delete its Data :\t"); 118 | String customerID = read1.nextLine(); 119 | if (customersCollection.size() > 0) { 120 | c1.deleteUser(customerID); 121 | } else { 122 | System.out.printf("%-50sNo Customer with the ID %s Found...!!!\n", " ", customerID); 123 | } 124 | } else if (desiredOption == 5) { 125 | /*Call the Display Method of Customer Class....*/ 126 | c1.displayArtWork(3); 127 | c1.displayCustomersData(false); 128 | } else if (desiredOption == 6) { 129 | bookingAndReserving.displayArtWork(6); 130 | c1.displayCustomersData(false); 131 | System.out.print("\n\nEnter the ID of the user to display all flights registered by that user..."); 132 | String id = read1.nextLine(); 133 | bookingAndReserving.displayFlightsRegisteredByOneUser(id); 134 | } else if (desiredOption == 7) { 135 | c1.displayArtWork(4); 136 | System.out.print("Do you want to display Passengers of all flights or a specific flight.... 'Y/y' for displaying all flights and 'N/n' to look for a" + 137 | " specific flight.... "); 138 | char choice = read1.nextLine().charAt(0); 139 | if ('y' == choice || 'Y' == choice) { 140 | bookingAndReserving.displayRegisteredUsersForAllFlight(); 141 | } else if ('n' == choice || 'N' == choice) { 142 | f1.displayFlightSchedule(); 143 | System.out.print("Enter the Flight Number to display the list of passengers registered in that flight... "); 144 | String flightNum = read1.nextLine(); 145 | bookingAndReserving.displayRegisteredUsersForASpecificFlight(flightNum); 146 | } else { 147 | System.out.println("Invalid Choice...No Response...!"); 148 | } 149 | } else if (desiredOption == 8) { 150 | c1.displayArtWork(5); 151 | f1.displayFlightSchedule(); 152 | System.out.print("Enter the Flight Number to delete the flight : "); 153 | String flightNum = read1.nextLine(); 154 | f1.deleteFlight(flightNum); 155 | 156 | } else if (desiredOption == 0) { 157 | bookingAndReserving.displayArtWork(22); 158 | System.out.println("Thanks for Using BAV Airlines Ticketing System...!!!"); 159 | 160 | } else { 161 | System.out.println("Invalid Choice...Looks like you're Robot...Entering values randomly...You've Have to login again..."); 162 | bookingAndReserving.displayArtWork(22); 163 | desiredOption = 0; 164 | } 165 | 166 | } while (desiredOption != 0); 167 | 168 | } 169 | } else if (desiredOption == 2) { 170 | printArtWork(2); 171 | /*If desiredOption is 2, then call the registration method to register a user......*/ 172 | System.out.print("\nEnter the UserName to Register : "); 173 | String username = read1.nextLine(); 174 | System.out.print("Enter the Password to Register : "); 175 | String password = read1.nextLine(); 176 | while (r1.isPrivilegedUserOrNot(username, password) != -1) { 177 | System.out.print("ERROR!!! Admin with same UserName already exist. Enter new UserName: "); 178 | username = read1.nextLine(); 179 | System.out.print("Enter the Password Again: "); 180 | password = read1.nextLine(); 181 | } 182 | 183 | /*Setting the credentials entered by the user.....*/ 184 | adminUserNameAndPassword[countNumOfUsers][0] = username; 185 | adminUserNameAndPassword[countNumOfUsers][1] = password; 186 | 187 | /*Incrementing the numOfUsers */ 188 | countNumOfUsers++; 189 | } else if (desiredOption == 3) { 190 | printArtWork(3); 191 | System.out.print("\n\nEnter the Email to Login : \t"); 192 | String userName = read1.nextLine(); 193 | System.out.print("Enter the Password : \t"); 194 | String password = read1.nextLine(); 195 | String[] result = r1.isPassengerRegistered(userName, password).split("-"); 196 | 197 | if (Integer.parseInt(result[0]) == 1) { 198 | int desiredChoice; 199 | System.out.printf("\n\n%-20sLogged in Successfully as \"%s\"..... For further Proceedings, enter a value from below....", "", userName); 200 | do { 201 | System.out.printf("\n\n%-60s+++++++++ 3rd Layer Menu +++++++++%50sLogged in as \"%s\"\n", "", "", userName); 202 | System.out.printf("%-40s (a) Enter 1 to Book a flight....\n", ""); 203 | System.out.printf("%-40s (b) Enter 2 to update your Data....\n", ""); 204 | System.out.printf("%-40s (c) Enter 3 to delete your account....\n", ""); 205 | System.out.printf("%-40s (d) Enter 4 to Display Flight Schedule....\n", ""); 206 | System.out.printf("%-40s (e) Enter 5 to Cancel a Flight....\n", ""); 207 | System.out.printf("%-40s (f) Enter 6 to Display all flights registered by \"%s\"....\n", "", userName); 208 | System.out.printf("%-40s (g) Enter 0 to Go back to the Main Menu/Logout....\n", ""); 209 | System.out.print("Enter the desired Choice : "); 210 | desiredChoice = read.nextInt(); 211 | if (desiredChoice == 1) { 212 | bookingAndReserving.displayArtWork(1); 213 | f1.displayFlightSchedule(); 214 | System.out.print("\nEnter the desired flight number to book :\t "); 215 | String flightToBeBooked = read1.nextLine(); 216 | System.out.print("Enter the Number of tickets for " + flightToBeBooked + " flight : "); 217 | int numOfTickets = read.nextInt(); 218 | while (numOfTickets > 10) { 219 | System.out.print("ERROR!! You can't book more than 10 tickets at a time for single flight....Enter number of tickets again : "); 220 | numOfTickets = read.nextInt(); 221 | } 222 | bookingAndReserving.bookFlight(flightToBeBooked, numOfTickets, result[1]); 223 | } else if (desiredChoice == 2) { 224 | bookingAndReserving.displayArtWork(2); 225 | c1.editUserInfo(result[1]); 226 | } else if (desiredChoice == 3) { 227 | bookingAndReserving.displayArtWork(3); 228 | System.out.print("Are you sure to delete your account...It's an irreversible action...Enter Y/y to confirm..."); 229 | char confirmationChar = read1.nextLine().charAt(0); 230 | if (confirmationChar == 'Y' || confirmationChar == 'y') { 231 | c1.deleteUser(result[1]); 232 | System.out.printf("User %s's account deleted Successfully...!!!", userName); 233 | desiredChoice = 0; 234 | } else { 235 | System.out.println("Action has been cancelled..."); 236 | } 237 | } else if (desiredChoice == 4) { 238 | bookingAndReserving.displayArtWork(4); 239 | f1.displayFlightSchedule(); 240 | f1.displayMeasurementInstructions(); 241 | } else if (desiredChoice == 5) { 242 | bookingAndReserving.displayArtWork(5); 243 | bookingAndReserving.cancelFlight(result[1]); 244 | } else if (desiredChoice == 6) { 245 | bookingAndReserving.displayArtWork(6); 246 | bookingAndReserving.displayFlightsRegisteredByOneUser(result[1]); 247 | } else { 248 | bookingAndReserving.displayArtWork(7); 249 | if (desiredChoice != 0) { 250 | System.out.println("Invalid Choice...Looks like you're Robot...Entering values randomly...You've Have to login again..."); 251 | } 252 | desiredChoice = 0; 253 | } 254 | } while (desiredChoice != 0); 255 | 256 | } else { 257 | System.out.printf("\n%20sERROR!!! Unable to login Cannot find user with the entered credentials.... Try Creating New Credentials or get yourself register by pressing 4....\n", ""); 258 | } 259 | } else if (desiredOption == 4) { 260 | printArtWork(4); 261 | c1.addNewCustomer(); 262 | } else if (desiredOption == 5) { 263 | manualInstructions(); 264 | } 265 | 266 | displayMainMenu(); 267 | desiredOption = read1.nextInt(); 268 | while (desiredOption < 0 || desiredOption > 8) { 269 | System.out.print("ERROR!! Please enter value between 0 - 4. Enter the value again :\t"); 270 | desiredOption = read1.nextInt(); 271 | } 272 | } while (desiredOption != 0); 273 | welcomeScreen(-1); 274 | } 275 | 276 | static void displayMainMenu() { 277 | System.out.println("\n\n\t\t(a) Press 0 to Exit."); 278 | System.out.println("\t\t(b) Press 1 to Login as admin."); 279 | System.out.println("\t\t(c) Press 2 to Register as admin."); 280 | System.out.println("\t\t(d) Press 3 to Login as Passenger."); 281 | System.out.println("\t\t(e) Press 4 to Register as Passenger."); 282 | System.out.println("\t\t(f) Press 5 to Display the User Manual."); 283 | System.out.print("\t\tEnter the desired option: "); 284 | } 285 | 286 | static void manualInstructions() { 287 | Scanner read = new Scanner(System.in); 288 | System.out.printf("%n%n%50s %s Welcome to BAV Airlines User Manual %s", "", "+++++++++++++++++", "+++++++++++++++++"); 289 | System.out.println("\n\n\t\t(a) Press 1 to display Admin Manual."); 290 | System.out.println("\t\t(b) Press 2 to display User Manual."); 291 | System.out.print("\nEnter the desired option : "); 292 | int choice = read.nextInt(); 293 | while (choice < 1 || choice > 2) { 294 | System.out.print("ERROR!!! Invalid entry...Please enter a value either 1 or 2....Enter again...."); 295 | choice = read.nextInt(); 296 | } 297 | if (choice == 1) { 298 | System.out.println("\n\n(1) Admin have the access to all users data...Admin can delete, update, add and can perform search for any customer...\n"); 299 | System.out.println("(2) In order to access the admin module, you've to get yourself register by pressing 2, when the main menu gets displayed...\n"); 300 | System.out.println("(3) Provide the required details i.e., name, email, id...Once you've registered yourself, press 1 to login as an admin... \n"); 301 | System.out.println("(4) Once you've logged in, 2nd layer menu will be displayed on the screen...From here on, you can select from variety of options...\n"); 302 | System.out.println("(5) Pressing \"1\" will add a new Passenger, provide the program with required details to add the passenger...\n"); 303 | System.out.println("(6) Pressing \"2\" will search for any passenger, given the admin(you) provides the ID from the table printing above.... \n"); 304 | System.out.println("(7) Pressing \"3\" will let you update any passengers data given the user ID provided to program...\n"); 305 | System.out.println("(8) Pressing \"4\" will let you delete any passenger given its ID provided...\n"); 306 | System.out.println("(9) Pressing \"5\" will let you display all registered passenger...\n"); 307 | System.out.println("(10) Pressing \"6\" will let you display all registered passengers...After selecting, program will ask, if you want to display passengers for all flights(Y/y) or a specific flight(N/n)\n"); 308 | System.out.println("(11) Pressing \"7\" will let you delete any flight given its flight number provided...\n"); 309 | System.out.println("(11) Pressing \"0\" will make you logged out of the program...You can login again any time you want during the program execution....\n"); 310 | } else { 311 | System.out.println("\n\n(1) Local user has the access to its data only...He/She won't be able to change/update other users data...\n"); 312 | System.out.println("(2) In order to access local users benefits, you've to get yourself register by pressing 4, when the main menu gets displayed...\n"); 313 | System.out.println("(3) Provide the details asked by the program to add you to the users list...Once you've registered yourself, press \"3\" to login as a passenger...\n"); 314 | System.out.println("(4) Once you've logged in, 3rd layer menu will be displayed...From here on, you embarked on the journey to fly with us...\n"); 315 | System.out.println("(5) Pressing \"1\" will display available/scheduled list of flights...To get yourself booked for a flight, enter the flight number and number of tickets for the flight...Max num of tickets at a time is 10 ...\n"); 316 | System.out.println("(7) Pressing \"2\" will let you update your own data...You won't be able to update other's data... \n"); 317 | System.out.println("(8) Pressing \"3\" will delete your account... \n"); 318 | System.out.println("(9) Pressing \"4\" will display randomly designed flight schedule for this runtime...\n"); 319 | System.out.println("(10) Pressing \"5\" will let you cancel any flight registered by you...\n"); 320 | System.out.println("(11) Pressing \"6\" will display all flights registered by you...\n"); 321 | System.out.println("(12) Pressing \"0\" will make you logout of the program...You can login back at anytime with your credentials...for this particular run-time... \n"); 322 | } 323 | } 324 | 325 | static void welcomeScreen(int option) { 326 | String artWork; 327 | 328 | if (option == 1) { 329 | artWork = """ 330 | 331 | 888 888 888 888 888888b. d8888 888 888 d8888 d8b 888 d8b \s 332 | 888 o 888 888 888 888 "88b d88888 888 888 d88888 Y8P 888 Y8P \s 333 | 888 d8b 888 888 888 888 .88P d88P888 888 888 d88P888 888 \s 334 | 888 d888b 888 .d88b. 888 .d8888b .d88b. 88888b.d88b. .d88b. 888888 .d88b. 8888888K. d88P 888 Y88b d88P d88P 888 888 888d888 888 888 88888b. .d88b. .d8888b \s 335 | 888d88888b888 d8P Y8b 888 d88P" d88""88b 888 "888 "88b d8P Y8b 888 d88""88b 888 "Y88b d88P 888 Y88b d88P d88P 888 888 888P" 888 888 888 "88b d8P Y8b 88K \s 336 | 88888P Y88888 88888888 888 888 888 888 888 888 888 88888888 888 888 888 888 888 d88P 888 Y88o88P d88P 888 888 888 888 888 888 888 88888888 "Y8888b.\s 337 | 8888P Y8888 Y8b. 888 Y88b. Y88..88P 888 888 888 Y8b. Y88b. Y88..88P 888 d88P d8888888888 Y888P d8888888888 888 888 888 888 888 888 Y8b. X88\s 338 | 888P Y888 "Y8888 888 "Y8888P "Y88P" 888 888 888 "Y8888 "Y888 "Y88P" 8888888P" d88P 888 Y8P d88P 888 888 888 888 888 888 888 "Y8888 88888P'\s 339 | \s 340 | \s 341 | \s 342 | """; 343 | } else { 344 | artWork = """ 345 | 346 | 347 | 348 | 349 | d88888b db db db d888888b d8b db d888b db d8b db d888888b d888888b db db d888888b d8888b. db db .d8888. d888888b \s 350 | 88' 88 `8b d8' `88' 888o 88 88' Y8b 88 I8I 88 `88' `~~88~~' 88 88 `~~88~~' 88 `8D 88 88 88' YP `~~88~~' \s 351 | 88ooo 88 `8bd8' 88 88V8o 88 88 88 I8I 88 88 88 88ooo88 88 88oobY' 88 88 `8bo. 88 \s 352 | 88~~~ 88 88 88 88 V8o88 88 ooo Y8 I8I 88 88 88 88~~~88 88 88`8b 88 88 `Y8b. 88 \s 353 | 88 88booo. 88 .88. 88 V888 88. ~8~ `8b d8'8b d8' .88. 88 88 88 88 88 `88. 88b d88 db 8D 88 \s 354 | YP Y88888P YP Y888888P VP V8P Y888P `8b8' `8d8' Y888888P YP YP YP YP 88 YD ~Y8888P' `8888Y' YP \s 355 | \s 356 | \s 357 | d88888b .d88b. d8888b. d88888b d888888b db db d88888b d8888b. d88888b .o88b. .d8b. d8888b. d88888b .d8888. db\s 358 | 88' .8P Y8. 88 `8D 88' `88' 88 88 88' 88 `8D 88' d8P Y8 d8' `8b 88 `8D 88' 88' YP 88\s 359 | 88ooo 88 88 88oobY' 88ooo 88 Y8 8P 88ooooo 88 88 88ooooo 8P 88ooo88 88 88 88ooooo `8bo. YP\s 360 | 88~~~ 88 88 88`8b 88~~~ 88 `8b d8' 88~~~~~ 88 88 88~~~~~ 8b 88~~~88 88 88 88~~~~~ `Y8b. \s 361 | 88 `8b d8' 88 `88. 88 .88. `8bd8' 88. 88 .8D 88. Y8b d8 88 88 88 .8D 88. db 8D db db db db db\s 362 | YP `Y88P' 88 YD YP Y888888P YP Y88888P Y8888D' Y88888P `Y88P' YP YP Y8888D' Y88888P `8888Y' VP VP VP VP YP\s 363 | \s 364 | \s 365 | """; 366 | } 367 | System.out.println(artWork); 368 | } 369 | 370 | static void printArtWork(int option) { 371 | String artWork; 372 | if (option == 4) { 373 | artWork = """ 374 | 375 | .o88b. db db .d8888. d888888b .d88b. .88b d88. d88888b d8888b. .d8888. d888888b d888b d8b db db db d8888b.\s 376 | d8P Y8 88 88 88' YP `~~88~~' .8P Y8. 88'YbdP`88 88' 88 `8D 88' YP `88' 88' Y8b 888o 88 88 88 88 `8D\s 377 | 8P 88 88 `8bo. 88 88 88 88 88 88 88ooooo 88oobY' `8bo. 88 88 88V8o 88 88 88 88oodD'\s 378 | 8b 88 88 `Y8b. 88 88 88 88 88 88 88~~~~~ 88`8b `Y8b. 88 88 ooo 88 V8o88 88 88 88~~~ \s 379 | Y8b d8 88b d88 db 8D 88 `8b d8' 88 88 88 88. 88 `88. db 8D .88. 88. ~8~ 88 V888 88b d88 88 \s 380 | `Y88P' ~Y8888P' `8888Y' YP `Y88P' YP YP YP Y88888P 88 YD `8888Y' Y888888P Y888P VP V8P ~Y8888P' 88 \s 381 | \s 382 | \s 383 | """; 384 | } else if (option == 3) { 385 | artWork = """ 386 | 387 | .o88b. db db .d8888. d888888b .d88b. .88b d88. d88888b d8888b. db .d88b. d888b d888888b d8b db\s 388 | d8P Y8 88 88 88' YP `~~88~~' .8P Y8. 88'YbdP`88 88' 88 `8D 88 .8P Y8. 88' Y8b `88' 888o 88\s 389 | 8P 88 88 `8bo. 88 88 88 88 88 88 88ooooo 88oobY' 88 88 88 88 88 88V8o 88\s 390 | 8b 88 88 `Y8b. 88 88 88 88 88 88 88~~~~~ 88`8b 88 88 88 88 ooo 88 88 V8o88\s 391 | Y8b d8 88b d88 db 8D 88 `8b d8' 88 88 88 88. 88 `88. 88booo. `8b d8' 88. ~8~ .88. 88 V888\s 392 | `Y88P' ~Y8888P' `8888Y' YP `Y88P' YP YP YP Y88888P 88 YD Y88888P `Y88P' Y888P Y888888P VP V8P\s 393 | \s 394 | \s 395 | """; 396 | } else if (option == 2) { 397 | artWork = """ 398 | 399 | .d8b. d8888b. .88b d88. d888888b d8b db .d8888. d888888b d888b d8b db db db d8888b.\s 400 | d8' `8b 88 `8D 88'YbdP`88 `88' 888o 88 88' YP `88' 88' Y8b 888o 88 88 88 88 `8D\s 401 | 88ooo88 88 88 88 88 88 88 88V8o 88 `8bo. 88 88 88V8o 88 88 88 88oodD'\s 402 | 88~~~88 88 88 88 88 88 88 88 V8o88 `Y8b. 88 88 ooo 88 V8o88 88 88 88~~~ \s 403 | 88 88 88 .8D 88 88 88 .88. 88 V888 db 8D .88. 88. ~8~ 88 V888 88b d88 88 \s 404 | YP YP Y8888D' YP YP YP Y888888P VP V8P `8888Y' Y888888P Y888P VP V8P ~Y8888P' 88 \s 405 | \s 406 | \s 407 | \s"""; 408 | } else { 409 | artWork = """ 410 | 411 | .d8b. d8888b. .88b d88. d888888b d8b db db .d88b. d888b d888888b d8b db\s 412 | d8' `8b 88 `8D 88'YbdP`88 `88' 888o 88 88 .8P Y8. 88' Y8b `88' 888o 88\s 413 | 88ooo88 88 88 88 88 88 88 88V8o 88 88 88 88 88 88 88V8o 88\s 414 | 88~~~88 88 88 88 88 88 88 88 V8o88 88 88 88 88 ooo 88 88 V8o88\s 415 | 88 88 88 .8D 88 88 88 .88. 88 V888 88booo. `8b d8' 88. ~8~ .88. 88 V888\s 416 | YP YP Y8888D' YP YP YP Y888888P VP V8P Y88888P `Y88P' Y888P Y888888P VP V8P\s 417 | \s 418 | \s 419 | """; 420 | } 421 | 422 | System.out.println(artWork); 423 | } 424 | 425 | // ************************************************************ Setters & Getters ************************************************************ 426 | 427 | public static List getCustomersCollection() { 428 | return customersCollection; 429 | } 430 | } --------------------------------------------------------------------------------