Tammy Culp

Tammy Culp

  • NA
  • 1
  • 0

AirLine Reservation code need help with bool

Apr 11 2010 9:05 PM

Here is what I have so far however I am having trouble getting the Bool to work so that it does not assign the same seat twice.  Seat capasity is 1-5 1st class 6-10 Economy.


Please help


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace _8._19

{

    class Program

    {

        static void Main(string[] args)

        // Description: main entry point of program

        //  Parameters: none

        //     Returns: nothing

        {

            Random rand = new Random();

            bool[] seats = new bool[10];

            int inputI = 0;

            char inputC = ' ';

            bool quit = false;

            do

            {

                Console.Clear();

                int seatAssignF = rand.Next(0, 5);

                int seatAssignE = rand.Next(5, 10);

                Console.WriteLine("Please type [1] for First Class

                                  \nPlease type [2] for Economy

                                  \nPlease type [3] to exit the order system");

                inputI = Int32.Parse(Console.ReadLine());

                switch (inputI)

                {

                    case 1:

                        seats[seatAssignF] = true;

                        Console.WriteLine("Your seat: {0}", seatAssignF + 1);

                        Console.WriteLine("Press enter to continue...");

                        Console.ReadLine();

                        break;

                    case 2:

                        seats[seatAssignE] = true;

                        Console.WriteLine("Your seat: {0}", seatAssignE + 1);

                        Console.WriteLine("Press enter to continue...");

                        Console.ReadLine();

                        break;

                    case 3:

                        quit = true;

                        break;

                    default:

                        Console.WriteLine("ERROR::INVALID SELECTION");

                        quit = true;

                        break;

                }

            } while (!quit);

        }

    }

}



Thx

Tammy