src/ManageConnections.c
/*
 * FUNCTION NAME: changeDistanceMenu
 *
 * DESCRIPTION:
 * Function gets city1, city2 and a new distance
 * between these cities.
 * Then runs changeDistance() function.
 */
FUNCTION NAME: changeDistanceMenu
DESCRIPTION:
Function gets city1, city2 and a new distance
between these cities.
Then runs changeDistance() function.
FUNCTION NAME : changeDistanceMenu DESCRIPTION : Function gets city1 city2 and a new distance between these cities . Then runs changeDistance () function .
void changeDistanceMenu(Graph_t* graph)
{
    programError_t what_error = NO_ERROR;
    char city1[G_CITYS_NAME_LENGTH];
    char city2[G_CITYS_NAME_LENGTH];
    double distance = 0;
    int counter = 2;
    if (graph->head == NULL) {
        printErrorUsersActions(EMPTY_GRAPH);
        return;
    }
    do {
        if ((counter % 4) == 1) {
            showCityList(graph);
        }
        ++counter;
        printErrorUsersActions(what_error);
        getCitysName(FIRST_CITY, city1);
        what_error = checkIfNameIsCorrect(city1);
        if (what_error == NO_ERROR) {
            what_error = checkIfIsInGraph(graph, city1);
        }
    } while (what_error != NO_ERROR);
    counter = 2;
    do {
        if ((counter % 4) == 1) {
            showConnections(graph);
        }
        ++counter;
        printErrorUsersActions(what_error);
        getCitysName(SECOND_CITY, city2);
        what_error = checkIfNameIsCorrect(city2);
        if (what_error == NO_ERROR)
            what_error = checkIfIsInGraph(graph, city2);
        if (what_error == NO_ERROR)
            what_error = checkIfNamesAreIdentical(city1, city2);
        if (what_error == NO_ERROR) {
            if (CONNECTION_ALREADY_IN_GRAPH == checkIfConnectionIsInGraph(graph, city1, city2)) {
                what_error = NO_ERROR;
            } else {
                what_error = NO_SUCH_CONNECTION;
            }
        }
    } while (what_error != NO_ERROR);
    do {
        printErrorUsersActions(what_error);
        getDistanceBetweenCities(&distance);
        what_error = checkIfDistanceIsCorrect(distance);
    } while (what_error != NO_ERROR);
    changeDistance(graph, city1, city2, distance);
    clearBuffer();
}
void changeDistanceMenu ( Graph_t * graph ) { programError_t what_error = NO_ERROR ; char city1 [ G_CITYS_NAME_LENGTH ] ; char city2 [ G_CITYS_NAME_LENGTH ] ; double distance = 0 ; int counter = 2 ; if ( graph -> head == NULL ) { printErrorUsersActions ( EMPTY_GRAPH ) ; return ; } do { if ( ( counter % 4 ) == 1 ) { showCityList ( graph ) ; } ++ counter ; printErrorUsersActions ( what_error ) ; getCitysName ( FIRST_CITY , city1 ) ; what_error = checkIfNameIsCorrect ( city1 ) ; if ( what_error == NO_ERROR ) { what_error = checkIfIsInGraph ( graph , city1 ) ; } } while ( what_error != NO_ERROR ) ; counter = 2 ; do { if ( ( counter % 4 ) == 1 ) { showConnections ( graph ) ; } ++ counter ; printErrorUsersActions ( what_error ) ; getCitysName ( SECOND_CITY , city2 ) ; what_error = checkIfNameIsCorrect ( city2 ) ; if ( what_error == NO_ERROR ) what_error = checkIfIsInGraph ( graph , city2 ) ; if ( what_error == NO_ERROR ) what_error = checkIfNamesAreIdentical ( city1 , city2 ) ; if ( what_error == NO_ERROR ) { if ( CONNECTION_ALREADY_IN_GRAPH == checkIfConnectionIsInGraph ( graph , city1 , city2 ) ) { what_error = NO_ERROR ; } else { what_error = NO_SUCH_CONNECTION ; } } } while ( what_error != NO_ERROR ) ; do { printErrorUsersActions ( what_error ) ; getDistanceBetweenCities ( & distance ) ; what_error = checkIfDistanceIsCorrect ( distance ) ; } while ( what_error != NO_ERROR ) ; changeDistance ( graph , city1 , city2 , distance ) ; clearBuffer ( ) ; }
FUNCTION NAME: changeDistanceMenu
 DESCRIPTION:
 Function gets city1, city2 and a new distance
 between these cities.
FUNCTION NAME : changeDistanceMenu DESCRIPTION : Function gets city1 city2 and a new distance between these cities .
/* Check if connection is or is not already in the graph */