src/ManageCities.c
/*
 * FUNCTION NAME: renameCityMenu
 *
 * DESCRIPTION:
 * Function gets city's name and then calls a function to
 * rename it.
 */
FUNCTION NAME: renameCityMenu
DESCRIPTION:
Function gets city's name and then calls a function to
rename it.
FUNCTION NAME : renameCityMenu DESCRIPTION : Function gets city ' s name and then calls a function to rename it .
void renameCityMenu(Graph_t* graph)
{
    if (graph->head == NULL) {
        printErrorUsersActions(EMPTY_GRAPH);
        return;
    }
    char city[G_CITYS_NAME_LENGTH];
    char new_citys_name[G_CITYS_NAME_LENGTH];
    programError_t what_error = NO_ERROR;
    int counter = 2;
    do {
        if ((counter % 4) == 1) {
            showCityList(graph);
        }
        ++counter;
        printErrorUsersActions(what_error);
        getCitysName(RENAME_CITY, city);
        what_error = checkIfNameIsCorrect(city);
        if (what_error == NO_ERROR) {
            what_error = checkIfIsInGraph(graph, city);
        }
    } while (what_error != NO_ERROR);
    counter = 2;
    do {
        if ((counter % 4) == 1) {
            showCityList(graph);
        }
        ++counter;
        printErrorUsersActions(what_error);
        getCitysName(NEW_CITYS_NAME, new_citys_name);
        what_error = checkIfNameIsCorrect(new_citys_name);
        if (what_error == NO_ERROR) {
            what_error = checkIfNamesAreIdentical(city, new_citys_name);
        }
        if (what_error == NO_ERROR) {
            what_error = checkIfIsInGraph(graph, new_citys_name);
            if (what_error != NO_SUCH_CITY) {
                what_error = CITY_ALREADY_IN_GRAPH;
            } else {
                what_error = NO_ERROR;
            }
        }
    } while (what_error != NO_ERROR);
    renameCity(graph, city, new_citys_name);
}
void renameCityMenu ( Graph_t * graph ) { if ( graph -> head == NULL ) { printErrorUsersActions ( EMPTY_GRAPH ) ; return ; } char city [ G_CITYS_NAME_LENGTH ] ; char new_citys_name [ G_CITYS_NAME_LENGTH ] ; programError_t what_error = NO_ERROR ; int counter = 2 ; do { if ( ( counter % 4 ) == 1 ) { showCityList ( graph ) ; } ++ counter ; printErrorUsersActions ( what_error ) ; getCitysName ( RENAME_CITY , city ) ; what_error = checkIfNameIsCorrect ( city ) ; if ( what_error == NO_ERROR ) { what_error = checkIfIsInGraph ( graph , city ) ; } } while ( what_error != NO_ERROR ) ; counter = 2 ; do { if ( ( counter % 4 ) == 1 ) { showCityList ( graph ) ; } ++ counter ; printErrorUsersActions ( what_error ) ; getCitysName ( NEW_CITYS_NAME , new_citys_name ) ; what_error = checkIfNameIsCorrect ( new_citys_name ) ; if ( what_error == NO_ERROR ) { what_error = checkIfNamesAreIdentical ( city , new_citys_name ) ; } if ( what_error == NO_ERROR ) { what_error = checkIfIsInGraph ( graph , new_citys_name ) ; if ( what_error != NO_SUCH_CITY ) { what_error = CITY_ALREADY_IN_GRAPH ; } else { what_error = NO_ERROR ; } } } while ( what_error != NO_ERROR ) ; renameCity ( graph , city , new_citys_name ) ; }
FUNCTION NAME: renameCityMenu
 DESCRIPTION:
 Function gets city's name and then calls a function to
 rename it.
FUNCTION NAME : renameCityMenu DESCRIPTION : Function gets city ' s name and then calls a function to rename it .