Question: ---------------- C# Programming Language --------------------------- Create new solution/project any name as Console/DotNet Framework application. You will implement a program that repeatedly displays and handles options

---------------- C# Programming Language ---------------------------

Create new solution/project any name as Console/DotNet Framework application.

You will implement a program that repeatedly displays and handles options of the following menu items:

Menu:

1. Add Airport 2. List all airports 3. Find nearest airport by code 4. Find airport's elevation standard deviation 5. Change log delegates 0. Exit Enter your choice:

Define the following class Airport. - Add getters and setters with verification that throw InvalidDataException on any failure. - Add constructor that takes 5 parameters to initialize the 5 fields. - Add constructor that takes 1 string parameter which is a line in file that it will parse and use to create Airport object. - Add ToString implementation to display data in user-friendly manner. - Add ToDataString implementation to save data to file as a single line semicolon-separated.

class Airport { Airport(string code, string city, double lat, double lng, int elevM) { ... } Airport(string dataLine) { ... } string Code; // exactly 3 uppercase letters, use regexp string City; // 1-50 characters, made up of uppercase and lowercase letters, digits, and .,- characters double Latitude, Longitude; // -90 to 90, -180 to 180 int ElevationMeters; -1000 to 10000 string ToString() { ... } string ToDataString() { ... } }

Define custom exception InvalidDataException with one constructor that takes string as parameter - the message describing the problem.

To Airport class add - static field named Logger of LoggerDelegate - delegate type LoggerDelegate that returns void and takes 1 parameter which is the message to be logged

In the main class Program define: - List static field AirportsList - methods to read and write data to file @"..\..\data.txt" (define a const for it): static void ReadDataFromFile() { ... } // file not found is not an error static void WriteDataToFile() { ... } Data will be read once when program begins and written back once when program is about to finish.

- methods for logging added to the main Program class public static void LogToConsole(string) { ... } public static void LogToFile(string) { ... } Logging to file must prefix each line with time stamp in yyyy-mm-dd hh:mm:ss format.

Logger methods will append to @"..\..\events.log" file.

You should call Logger for each of the following events in AIrport: - contructor called - exception thrown in setter or constructor

Initially Logger is null - no logging occurs.

For the distance between airports you are allowed to search web and copy an algorithm (method) that computes distance between two airports on a sphere using latitude/longitude. You may ignore elevation in this computation.

You must gracefully handle the case when there are no airports on the list or there is only one airport. If user enters airport code that is not found you display an error message and go back to the menu.

Example input file without errors. Note that you must gracefully handle cases where data in file is invalid in some ways by informing the user and skipping that line.

YUL;Montreal;45.4697842;-73.7554174;36 YYZ;Toronto;43.6777215;-79.6270084;173 JFK;New York JFK;40.6413151;-73.7803278;4 YVR;Vancouver;49.1966913;-123.183701;4

Example program session:

Data read from file.

1. Add Airport 2. List all airports 3. Find nearest airport by code 4. Find airport's elevation standard deviation 6. Change log delegates 0. Exit Enter your choice: 1

Adding airport Enter code: YUL Enter city: Montreal Enter latitude: 45.4659469 Enter longitude: 73.7497515 Enter elevation in meters: 37 Airport added.

1. Add Airport 2. List all airports 3. Find nearest airport by code 4. Find airport's elevation standard deviation 5. Change log delegates 0. Exit Enter your choice: 2

YYZ in Toronto at 43.6777215 lat / 79.6270084 lng at 68m elevation YUL in Montreal at 45.4659469 lat / 73.7497515 lng at 37m elevation

1. Add Airport 2. List all airports 3. Find nearest airport by code 4. Find airport's elevation standard deviation 5. Change log delegates 0. Exit Enter your choice: 3

Enter airport code: YUL Found nearest airport to be YYZ/Toronto distance is 487.34km

1. Add Airport 2. List all airports 3. Find nearest airport by code 4. Find airport's elevation standard deviation 5. Change log delegates 0. Exit Enter your choice: 4

For all airports the standard deviation of their elevation is 12.34

1. Add Airport 2. List all airports 3. Find nearest airport by code 4. Find airport's elevation standard deviation 5. Change log delegates 0. Exit Enter your choice: 5

Changing logging settings: 1-Logging to console 2-Logging to file Enter your choices, comma-separated, empty for none: 1,2 Logging to console enabled Logging to file enabled.

1. Add Airport 2. List all airports 3. Find nearest airport by code 4. Find airport's elevation standard deviation 5. Change log delegates 0. Exit Enter your choice: 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!