예제 #1
0
        static void Main(string[] args)
        {
            //AirlineService object used to show seating of airplane
            AirlineService airplane = new AirlineService();

            Console.WriteLine("Thank you for supporting Fly-By-Night Airlines. Here is our list of available seats: ");
            AirlineService.showSeating(airplane);
            int command = 0;

            //while seats are available and user does not type 4 to quit
            while (AirlineService.availableSeats && command != 4)
            {
                //outputs list of commands to choose from
                AirlineService.commandList();
                command = Convert.ToInt32(Console.ReadLine());
                //add passengers
                if (command == 1)
                {
                    Console.WriteLine("You chose to add passenger(s).");
                    AirlineService.addPassengers();
                }
                //show all airplane seatings
                else if (command == 2)
                {
                    Console.WriteLine("You chose to view seating.");
                    AirlineService.showSeating(airplane);
                }
                //collect all passengers info and write them to a single text file (One ticket per passenger).
                //note: text file deletes a previous text file with the same name
                else if (command == 3)
                {
                    Console.WriteLine("You chose to print out the tickets.");
                    int counter = AirlineService.ticketsPrinted;
                    //does not create text file if number of tickets printed match the current number of assigned seats
                    if (counter == AirlineService.tickets.Count)
                    {
                        Console.WriteLine("There are no tickets to print.");
                    }
                    else
                    {
                        if (counter == 0)
                        {
                            AirlineService.TicketPrinting(0);
                        }
                        else
                        {
                            AirlineService.TicketPrinting(counter);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Please input an integer ranging from 1 to 4.");
                }
            }
            Console.WriteLine("There are either no more seats available or you chose to quit program. Goodbye!");
            Console.ReadLine();
        }
예제 #2
0
        //shows the current state of airplane seats
        public static void showSeating(AirlineService a)
        {
            //string[,,] firstClass = new string[5,2,2];
            //string[,,] econClass = new string[15, 2, 3];
            Console.WriteLine("O = Spot Available. X = Spot Taken/Unavailable");
            Console.WriteLine("First Class: ");
            Console.WriteLine("        A" + "   " + "C" + "        " + "D" + "   " + "F");
            for (int i = 0; i < 5; i++)
            {
                if (i == 0)
                {
                    Console.Write("1       ");
                }
                else if (i == 1)
                {
                    Console.Write("2       ");
                }
                else if (i == 2)
                {
                    Console.Write("3       ");
                }
                else if (i == 3)
                {
                    Console.Write("4       ");
                }
                else
                {
                    Console.Write("5       ");
                }

                for (int j = 0; j < 2; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        Console.Write(firstClass[i, j, k] + "   ");
                    }
                    Console.Write("     ");
                }
                Console.WriteLine("");
            }
            Console.WriteLine("Economy Class:");
            Console.WriteLine("      A" + "  B " + " C" + "        " + "D" + "  E  " + "F");
            for (int i = 0; i < 15; i++)
            {
                if (i == 0)
                {
                    Console.Write("6     ");
                }
                else if (i == 1)
                {
                    Console.Write("7     ");
                }
                else if (i == 2)
                {
                    Console.Write("8     ");
                }
                else if (i == 3)
                {
                    Console.Write("9     ");
                }
                else if (i == 4)
                {
                    Console.Write("10    ");
                }
                else if (i == 5)
                {
                    Console.Write("11    ");
                }
                else if (i == 6)
                {
                    Console.Write("12    ");
                }
                else if (i == 7)
                {
                    Console.Write("13    ");
                }
                else if (i == 8)
                {
                    Console.Write("14    ");
                }
                else if (i == 9)
                {
                    Console.Write("15    ");
                }
                else if (i == 10)
                {
                    Console.Write("16    ");
                }
                else if (i == 11)
                {
                    Console.Write("17    ");
                }
                else if (i == 12)
                {
                    Console.Write("18    ");
                }
                else if (i == 13)
                {
                    Console.Write("19    ");
                }
                else
                {
                    Console.Write("20    ");
                }

                for (int j = 0; j < 2; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        Console.Write(econClass[i, j, k] + "  ");
                    }
                    Console.Write("      ");
                }
                Console.WriteLine("");
            }
        }