public string RegisterAircraft(AirCraft craft) { string flightnumber = string.Empty; Random random = new Random(); do { int asciiNr = random.Next(48, 91); if (asciiNr >= 58 && asciiNr < 65) { continue; } flightnumber += (char)asciiNr; } while (flightnumber.Length < 6); craft.flight_number = flightnumber; craft.status = FlightStatus.takeoffToBeRequested; Aeroplanes.Add(craft); return(flightnumber); }
static void Main(string[] args) { ControlTower controlTower = new ControlTower(); int choice = 0; while (choice != 6) { Console.WriteLine("============================================"); Console.WriteLine(" CONTROL TOWER MENU"); Console.WriteLine("============================================"); Console.WriteLine("\t1. Add track"); Console.WriteLine("\t2. Register Aeroplane"); Console.WriteLine("\t3. Control Tower Overview"); Console.WriteLine("\t4. Request Take Off"); Console.WriteLine("\t5. Take Off"); Console.WriteLine("\t6. Stop"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("Enter choice : "); choice = Convert.ToInt32(Console.ReadLine()); if (choice > 6 || choice < 1) { Console.WriteLine("Choose from 1-6 only ! "); } switch (choice) { case 1: Console.WriteLine("Enter Track Code : "); string tc = Console.ReadLine(); controlTower.AddTrack(tc); Console.WriteLine("\nTrack OverView : "); Console.WriteLine(controlTower.OverviewTracks()); break; case 2: string fNo = controlTower.RegisterAircraft(new AirCraft()); Console.WriteLine("Aeroplane was registered. Flight Number : " + fNo); Console.WriteLine("\nAircrafts OverView : "); Console.WriteLine(controlTower.OverviewAircraft()); break; case 3: Console.WriteLine("Track OverView : "); Console.WriteLine(controlTower.OverviewTracks()); Console.WriteLine("Aircrafts OverView : "); Console.WriteLine(controlTower.OverviewAircraft()); break; case 4: Console.WriteLine("Enter the flight number : "); fNo = Console.ReadLine(); Console.WriteLine(controlTower.RequestTakeOff(fNo)); break; case 5: Console.WriteLine("Enter the flight number : "); fNo = Console.ReadLine(); AirCraft craft = controlTower.SearchAircraft(fNo); Console.WriteLine(craft.TakeOff()); break; case 6: break; } } }