Aircraft auto-pilots navigate using a flight plan. This is a collection of locations which must be flown over/to. These are called waypoints. For example flying from Hobart (international code YMHB) to Brisbane (YBBN) the plane flies over Merimbula (YMER) in New South Wales. In addition to a name, each waypoint also consists of a coordinate. Merimbulas coordinate is 55H 758488 5911327. This has three parts: a grid reference (55H), an easting (758488), and a northing (5911327).
All the waypoints from the origin (for example Hobart) to the destination (for example Brisbane) would be collected together in an ordered list with a cursor which refers to the upcoming waypoint on the journey, the origin if the plane isnt in flight yet, or the destination if the plane has already landed. There is no restriction on the number of included waypoints on a flight path and no need to do anything other than have the cursor advance/retreat from one waypoint to the next.
- Which underlying data structure (array or linked-list) will you use as a basis to model the flight plan? In twothree sentences, justify your answer.
- Which kind of abstract data type (binary tree, general tree, array, stack, priority queue, double-ended queue, set, list, ) would you use to model the flight plan? In two three sentences, justify your answer by indicating the functionality required.
The types required to implement this include the following:
struct waypoint_int { char name[5]; char grid[4]; long int easting; long int northing;
};
typedef struct waypoint_int *waypoint;
You may assume the existence of the following functions which work on waypoints:
void init_waypoint(waypoint *wp, char *m, char *g, long
int e, int n);
char *get_name(waypoint w); char *get_grid(waypoint w); long int get_easting(waypoint w); long int get_northing(waypoint w); void set_name(waypoint w, char *m); void set_grid(waypoint w, char *g); void set_easting(waypoint w, long int e); void set_northing(waypoint w, long int n);
You may further assume the existence of the following type declarations:
struct flight_path_int;
typedef struct flight_path_int *flight_path;
- Define the struct flight_path_int type based upon your choice in (a) and define all other required types.
- Define a function to create the flight path stub which consists only of the origin (which is the current location) and destination. The function should have the following function header:
void init_flight_path(flight_path *fp, waypoint origin, waypoint destination);
- Define a function to add a new waypoint to a flight path by inserting it into the list after the current location. If the given flight path is empty, an error message should be displayed and no addition should occur. Your definition should conform to the following function header:
void add_next(flight_path f, waypoint interim);
- Define a function to search the whole list of waypoints for a particular name, printing and returning the UTM of the located waypoint as a string. Using the example from above, searching for YMER should show the grid, easting, and northing values and yield: 55H 5911327 758488. If the desired waypoint is not present in the list you should not print anything and return . Your definition should conform to the following function header:
char *locate(flight_path f, char *name);
- Write the function heading() which returns the name of the next waypoint in the list. heading() takes a Boolean variable which indicates whether the plane is required to go into a holding pattern over the current location. If this is the case or if the plane is at the destination then heading() should yield the name of the current location. An error message should be displayed if the flight path is empty and should be returned. heading() should return
the name of the upcoming/current waypoint and has the following function header:
char *heading(flight_path f, bool holding);
- Write the function remaining()that traverses the list counting the number of waypoints from the current waypoint until the named waypoint. The count should be inclusive of the waypoint. If the third parameter is true the count is forwards from the current location to the destination, if false, the count is from the current location backwards to the origin. 1 should be returned if the waypoint name cannot be found in relevant portion of the list. remaining() has the following function header:
int remaining(flight_path f, char *name, bool onwards);
- Write the function skip() which deletes the next waypoint in the flight plan. If the flight plan is empty or if the cursor is at the destination an error message should be displayed and no change made. skip() should have the following function header:
void skip(flight_path f);
- Sometimes in flight an issue arises and the plane needs to return to where it has come from. For this to occur the flight path must be reversed. Write the reverse() function to invert an entire flight path. reverse() has the following function header:
void reverse(flight_path f);
Program specification
You must write one or more C programs to define the types and implement the functions discussed above. You should download a Visual Studio project as a starting point which comprises the following files:
- h and flight_path.c the Flight Path ADT as specified above. You must complete flight_path.c;
- h and waypoint.c the Waypoint ADT as specified above;
- c the file which contains the main() function and other functions which implement the required task.
You should add program files for all other types that you need based upon your choice in (a) above. Your program is probably correct if you see the following output:
Program Style
Your program should follow the following coding conventions:
- const variable identifiers should be used as much as possible, should be written all in upper case and should be declared before all other variables
- #defined symbols should be used for constant values if const is inappropriate
- variable identifiers should start with a lower case letter
- every if and if-else statement should have a block of code (i.e. collections of lines surrounded by { and }) for both the if part and the else part (if used)
- every do, for, and while loop should have a block of code (i.e. {}s)
- the keyword continue should not be used
- the keyword break should only be used as part of a switch statement
- opening and closing braces of a block should be aligned
- all code within a block should be aligned and indented 1 tab stop (or 4 spaces) from the braces marking this block
- global variables should be used sparingly with parameter lists used to pass information in and out of functions.
- commenting:
- There should be a block of header comment which includes at least
- file name
- student name
- student identity number
- a statement of the purpose of the program
- date o Each variable declaration should be commented
- There should be comments that identify groups of statements that do various parts of the task
- Comments should describe the strategy of the code and should not simply translate the C into English
- There should be a block of header comment which includes at least

![[Solved] KIT107 Assignment2](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] KIT107 Assignment1](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.