Commit 48697493 authored by Anon's avatar Anon

Finished product :)

parent e5b36dd5
import java.util.Scanner;
import java.util.Random;
import java.util.Random; //import all of the functionality
import java.text.DecimalFormat;
import java.util.Arrays;
public class Book {
private char[][] Seat;
private boolean booked = false;
static String[][] seatArray = { //The array is being created here
{"01","02","03", "04","05","06", "07","08","09"},
{"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"}, // the array will visually represent each seat
};
static String name = "";
static String city = "";
static String dest = "";
static String Flight = ""; //these are in the global so they can be accessed easily
static String Seated = "";
static String FlightClass = "";
public static void main(String[] args) {
// TODO Auto-generated method stub
DecimalFormat Format = new DecimalFormat("00");
Scanner input = new Scanner(System.in);
Scanner inputstring = new Scanner(System.in);
Seat = new char[10][9];
printSeat();
System.out.println("Enter name: ");
String name = input.next();
System.out.println("Enter name: "); //user will input their informaiton for the plane
name = input.next();
System.out.println("Enter Origin City: ");
String city = input.next();
city = input.next();
System.out.println("Enter Destination: ");
String dest = input.next();
//generate flight number
Random rando = new Random();
int Flightnum = rando.nextInt(27);
Flightnum += 1;
dest = input.next();
//Random flight number generator
int Flightnum = Generate(1,28);
System.out.println("Your flight number is");
System.out.println("FL" + Flightnum);
//Array
String[][] seat = new String[9][10];
booked = "XX";
Flight = "FL" + Flightnum;
//Visual Menu
//This will print out the visual menu
System.out.println("Choose what class you would like");
System.out.println("1\t First Class");
System.out.println("2\t Business Class");
System.out.println("3\t Economy Class");
System.out.println("Your choice:");
//input
//the user will input what class they will want
int choice = input.nextInt();
if(choice == 1) {
System.out.println("You will get a seat between 1-18");
int Picked = Generate(1,18);
String Seat = Format.format(Picked);
String Checked = Check(Seat);
if (Checked == "Available"){
System.out.println("ur ticket is booked m8");
}
FlightClass = "First Class";
}
else if(choice == 2) {
System.out.println("You will get a seat between 19-45");
int Picked = Generate(19,45);
String Seat = Format.format(Picked);
String Checked = Check(Seat);
if (Checked == "Available"){
System.out.println("ur ticket is booked m8");
}
FlightClass = "Business";
}
else
{
else if(choice ==3){
System.out.println("You will get a seat between 46-90");
int Picked = Generate(46,90);
String Seat = Format.format(Picked);
String Checked = Check(Seat);
if (Checked == "Available"){
System.out.println("ur ticket is booked m8");
}
System.out.println("Would you like to choose your seat? ");
String choice1 = inputstring.nextLine();
if(choice1 == "yes") {
FlightClass = "Economy";
}
System.out.println("\n|[ Boarding Pass |]\n" + // boarding pass being created
"Name : " + name + "\nFrom : " + city + "\nTo : " + dest +
"\nFlight Number : " + Flightnum + "\nSeat Number : " +Seated +
"\nClass of flight : " + FlightClass);
}
public static String Check (String SeatNo) { //function being ready to be called back
String Checked = "Unavailable";
for(int i = 0; i < 10; i++) {
for(int j = 0; j < 9; j++) {
if (seatArray[i][j] .equals(SeatNo)) {
System.out.println("your seat is : " + seatArray[i][j]);
seatArray[i][j] = "XX";
Checked = "Available";
Seated = SeatNo;
return Checked;
}
}
}
return Checked; //return the function
}
public static int Generate(int min, int max) {
int RandomNo = (int) ((Math.random()*((max - min)+1))+min);
return RandomNo; // Random number generator for the flight tickets
}
}
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