Commit 6605f01f authored by User's avatar User

comments and display adjustments

parent a1b4ad97
package ar;
import java.util.Scanner;
import java.util.Scanner;//import modules
import java.util.Random;
public class reservation{
public static String plane[][] = {{"XX", "XX", "XX"}, {"XX", "XX", "06"}, {"07", "08", "09"}, //Initialize the array which contains the plane seats
......@@ -12,21 +12,25 @@ public class reservation{
{"XX", "XX", "XX"}, {"XX", "XX", "XX"}, {"XX", "71", "72"},
{"73", "74", "75"}, {"76", "77", "78"}, {"79", "80", "81"},
{"82", "83", "84"}, {"85", "86", "87"}, {"88", "89", "90"}};
static Random random = new Random();
public static int randomflightnum(int min, int max){//declare flight number generator method
int num = (int)(Math.random()*((max-min)+1))+min;//generate random number
return num;//return generated number
}
public static void main(String[] args) {//main subprogram
Scanner input = new Scanner(System.in);
String choice = "";
String choice = "";//Initialise variables
String reserve = "", section = "";
String first = "", last = "", city = "", destination = "";
System.out.println("Hello and Welcome. We first need some details-");
System.out.print("Please enter your first name: ");
first = input.next();
System.out.print("Please enter your last name: ");
last = input.next();
System.out.print("Please enter your origin city: ");
city = input.next();
String first = "", last = "", city = "", destination = "";//variables for customer details
System.out.println("Hello and Welcome. We first need some details-");//print out welcome message
System.out.print("Please enter your first name: ");//print out customer detail headings which inform the user what to type in
first = input.next();//grabs input and assigns it to a variable to be held
System.out.print("Please enter your last name: ");//print out customer detail headings which inform the user what to type in
last = input.next();//grabs input and assigns it to a variable to be held
System.out.print("Please enter your origin city: ");//print out customer detail headings which inform the user what to type in
city = input.next();//grabs input and assigns it to a variable to be held
System.out.print("Please enter your flight destination: ");
destination = input.next();
destination = input.next();//print out customer detail headings which inform the user what to type in
while(true) {//loop to repeat code
System.out.print("Choose a flight Class-"//print out options to the user
+ "\nPlease Type 1 for First Class"
......@@ -34,18 +38,18 @@ public class reservation{
+ "\nPlease Type 3 for Economy \n");
switch(choice = input.next()) {//switch case to run different outcomes
case "1"://case if user chooses first class/1
section = "First class";
section = "First class";//assigns the chosen class to the variable to be used later on
System.out.println("You have Chosen First Class");//prints out the class that the user has chosen
boolean seat = false;
for(int p=0; p<6; p++) {
boolean seat = false;//boolean to check for available seats. Assumed that there are none
for(int p=0; p<6; p++) {//loop to go through seats in the first class rows
for(int q=0; q<3; q++) {
if(plane[p][q] != "XX") {
seat = true;
if(plane[p][q] != "XX") {//checks if array value is NOT EQUAL to XX which means that there is a seat available
seat = true;//value of the boolean is changed to signify presence of free seat
}
}
}
if(seat == true) {
while(true) {
if(seat == true) {//if statement to run code if seat is available
while(true) {//while loop to display options
System.out.println("Would you like to choose a seat?(Y/N)");
String choose = input.next();
switch(choose) {
......@@ -219,16 +223,18 @@ public class reservation{
}
}
public static void ticket(String first, String last, String city, String destination, String section, String reserve) {
System.out.println("Here are your ticket details:"
+ "\n|{BOARDING PASS}|"
System.out.println("Here are your ticket details:\n"
+ "\\n--------------------------"
+ "\n\t|{BOARDING PASS}|"
+ "\n Name: " + first + " " + last
+ "\n From: " + city
+ "\n To: " + destination
+ "\n Flight: "
+ "\n Flight: FL" + randomflightnum(1,28)
+ "\n Seat No.: " + reserve
+ "\n Section: " + section
+ "\n--------------------------");
System.out.println("Thanks for using our booking service");
System.out.println("Thanks for using our booking service"
+ "\n Updated Plane seat plan:-");
display(plane);
}
void main() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment