Beispiel #1
0
        private void edit_airport()
        {
            Console.Clear();

            if (airports_length == 0)
            {
                Andrew_Helpers.input_error("No airport data entered yet.");
                return;
            }

            string[] decisions =
            {
                "Add report to which airport?",
                get_airports_string(),
                "\n0: Back"
            };

            int decision = Andrew_Helpers.get_int(decisions, 0, airports_length);

            if (decision == 0)
            {
                return;
            }

            airports[decision - 1].edit_data_menu();
        }
        public void edit_data_menu()
        {
            while (true)
            {
                Console.Clear();
                string[] decisions =
                {
                    "1: Edit airport name. Currently: " + this.name,
                    "2: Edit airport Location. Currently: " + this.location,
                    "3: Edit airport runway charge. Currently: " + this.runway_charge.ToString("C"),
                    "4: Create airport report. There is currently " + this.report_count.ToString() + " reports.",
                    "\n0: Back"
                };

                int number = Andrew_Helpers.get_int(decisions);

                switch (number)
                {
                case (0):
                    Console.Clear();
                    return;

                case (1):
                    Console.Clear();
                    this.name = get_name();
                    break;

                case (2):
                    Console.Clear();
                    this.location = get_location();
                    break;

                case (3):
                    Console.Clear();
                    runway_charge = get_runway_charge();
                    break;

                case (4):
                    create_report();
                    break;

                default:
                    Andrew_Helpers.input_error();
                    break;
                }
            }
        }
Beispiel #3
0
        public void user_menu()
        {
            string[] decisions =
            {
                "Welcome to Airportz! What would you like to do?",
                "1: Add Airport Data",
                "2: View Statistical Report",
                "\n0: Exit"
            };

            while (true)
            {
                Console.Clear();


                int number = Andrew_Helpers.get_int(decisions, 0, 2);

                switch (number)
                {
                case (0):
                    Console.Clear();
                    int confirm = Andrew_Helpers.get_int("Would you like to exit the program?\n1: Yes\n2: No", 1, 2);
                    if (confirm == 1)
                    {
                        return;
                    }

                    break;

                case (1):
                    set_airport();
                    break;

                case (2):
                    show_airport_menu();
                    break;

                default:
                    Andrew_Helpers.input_error();
                    break;
                }
            }
        }
        public void airport_menu()
        {
            while (true)
            {
                Console.Clear();
                string[] decisions =
                {
                    "Welcome to the airport menu! Options: ",
                    "1: Add Airport Data",
                    "2: View Statistical Report",
                    "\n0: Exit"
                };

                int number = Andrew_Helpers.get_int(decisions, 0, 2);

                switch (number)
                {
                case (0):
                    return;

                case (1):
                    // Enter airport data
                    edit_data_menu();
                    break;

                case (2):
                    // View airport data in a report
                    Console.Clear();
                    show_all_data();
                    // pause to allow user to view report
                    Console.WriteLine("\nPress any key to continue...");
                    Console.ReadKey();
                    Console.Clear();
                    break;

                default:
                    Andrew_Helpers.input_error();
                    break;
                }
            }
        }
Beispiel #5
0
        private void show_airport_menu()
        {
            Console.Clear();

            if (airports_length == 0)
            {
                Andrew_Helpers.input_error("No airport data entered yet.");
                return;
            }

            string[] decisions =
            {
                "View statistical report for which airport?",
                get_airports_string(),                 // returns string of all airports
                "-1: View All Airports And Reports",
                "0: Back"
            };

            while (true)
            {
                int decision = Andrew_Helpers.get_int(decisions, -1, airports_length);

                if (decision == 0)
                {
                    return;
                }
                else if (decision == -1)
                {
                    show_all_airports_and_data();
                    Console.Clear();
                    continue;
                }

                Console.Clear();
                airports[decision - 1].show_all_data();
                Console.WriteLine("\nPress any key to continue...");
                Console.ReadKey();
                Console.Clear();
            }
        }
Beispiel #6
0
        private void set_airport()
        {
            string[] decisions =
            {
                "You are in the airport data menu! Options: ",
                "1: Create new airport entry",
                "2: Edit an existing airport entry",
                "3: Create report for an existing airport",
                "\n0: Back"
            };

            while (true)
            {
                Console.Clear();
                int decision = Andrew_Helpers.get_int(decisions, 0, 3);
                switch (decision)
                {
                case (0):
                    return;

                case (1):
                    create_new_airport();
                    break;

                case (2):
                    edit_airport();
                    break;

                case (3):
                    create_report();
                    break;

                default:
                    return;
                }
            }
        }
 private static decimal get_runway_charge()
 {
     return(Andrew_Helpers.get_decimal("Enter the runway charge for this airport: ", 1499.99M, 3500.00M));
 }
 private static string get_location()
 {
     return(Andrew_Helpers.get_string("Enter the location of this airport: ", "Location cannot be blank"));
 }
 private static string get_name()
 {
     return(Andrew_Helpers.get_string("Enter the name of this airport: ", "Name cannot be blank"));
 }
        public void create_report()
        {
            int month      = 0;
            int flights    = 0;
            int passengers = 0;

            int i = 0;             // user inputs values in order, we use i to iterate through forms

            // this code design is an "event handler"
            do
            {
                Console.Clear();
                switch (i)
                {
                case (0):
                    Console.WriteLine("Enter month of the report: ");
                    if (int.TryParse(Console.ReadLine(), out month))
                    {
                        if (month < 1 || month > 12)
                        {
                            Andrew_Helpers.input_error("Please enter a number between 1 and 12");
                        }
                        else
                        {
                            i++;                                     // iterate to next switch statement as valid month was inputted
                            if (reports[month - 1] != null)          // check if there's already a reporting existing in that index
                            {
                                string[] choices =
                                {
                                    "There is already a report for that month, overwrite?",
                                    "1: Yes", "2: No"
                                };

                                int decision = Andrew_Helpers.get_int(choices, 1, 2);
                                if (decision == 2)
                                {
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        Andrew_Helpers.input_error("Please enter a number");
                    }

                    Console.Clear();
                    break;

                case (1):
                    Console.WriteLine("Enter Flights: ");
                    if (int.TryParse(Console.ReadLine(), out flights))
                    {
                        if (flights < 0)
                        {
                            Andrew_Helpers.input_error("Please enter a positive number.");
                        }
                        else
                        {
                            i++;
                        }
                    }
                    else
                    {
                        Andrew_Helpers.input_error("Please enter a number");
                    }
                    Console.Clear();
                    break;

                case (2):
                    Console.WriteLine("Enter Passengers: ");
                    if (int.TryParse(Console.ReadLine(), out passengers))
                    {
                        if (passengers < 0)
                        {
                            Andrew_Helpers.input_error("Please enter a positive number.");
                        }
                        else
                        {
                            i++;
                        }
                    }
                    else
                    {
                        Andrew_Helpers.input_error("Please enter a number");
                    }
                    Console.Clear();
                    break;

                default:
                    i++;
                    break;
                }
            } while (i <= 2);             // breaks when all 3 questions have been asked

            // add report in appropriate place in report array
            this.reports[month - 1] = create_report(flights, passengers, month);

            // iterate report count
            report_count++;

            Console.Clear();
        }