Exemplo n.º 1
0
/**
 * Print board with moves, move type, and constraints based on cmatrix
 */
void Board::printBoard() {
    const char* fmt = (moves.size() < 100) ? "%2d " : "%3d ";
    if (moves.size() > 0) {
        printf("\nTotal number of moves: %d\n", (int)moves.size());
    }
    cout << endl;
    cout << ((moves.size() < 100) ? "   " : "    ");
    for (int i = 0; i < board_w; i++) {
        printf(fmt, i);
    }
    cout << endl;
    for (int y = 0; y < board_h; y++) {
        printf(fmt, y);
        for (int x = 0; x <  board_w; x++) {
            if (cmatrix[y][x].m_pointType == PointType::Nop) {
                cout << ((moves.size() < 100) ? " " : "  ");
                if (cmatrix[y][x].m_constraint == Box::NORMAL) {
                    cout << ".";
                }
                cout << ((moves.size() < 100) ? " " : " ");
            } else {
                printf(fmt, cmatrix[y][x].m_seq);
            }
        }
        cout << endl;
    }
    if (g_i) {
        press_enter_to_continue();
    }
}
Exemplo n.º 2
0
/**
 * Print board with interactive moves, move type based on basic cmatrix values
 */
void Board::printBoardBasic() {
    if (!g_v) {
        return;
    }
    cout << "  ";
    for (int i = 0; i < board_w; i++) {
        printf("%2d ", i);
    }
    cout << endl;
    for (int y = 0; y < board_h; y++) {
        printf("%2d ", y);
        for (int x = 0; x <  board_w; x++) {
            if (cmatrix[y][x].m_pointType == PointType::Nop) { // no move on this square
                cout << ".";
            } else { // print desired symbol based on move (point) type
                if (cmatrix[y][x].m_pointType == PointType::Start) {
                    cout << "S";
                } else if (cmatrix[y][x].m_pointType == PointType::End) {
                    cout << "E";
                } else if (cmatrix[y][x].m_pointType == PointType::Normal) {
                    if (cmatrix[y][x].m_x == currentMove.m_x && cmatrix[y][x].m_y == currentMove.m_y) {
                        cout << "K";
                    } else {
                        cout << "x";
                    }
                }

            }
            cout << "  ";
        }
        cout << endl;
    }
    if (g_i) {
        press_enter_to_continue();
    }
}
Exemplo n.º 3
0
int
main(const int argc, const char *argv[])
{
    PERSON *ajout = NULL;
    int choice = 0;
    char temp[3] = "";

    clear_screen();

    create_users_file(USERSFILE);

    set_index_birthdays();

    check_argument(argc, argv);

    do
    {
        printf("\t\n1. Encoder un nouvel anniversaire");
        printf("\t\n2. Afficher les anniversaires");
        printf("\t\n3. Charger un fichier d'anniversaires");
        printf("\t\n4. Sauvegarder les anniversaires sur fich ier");
        printf("\t\n5. Afficher le prochain anniversaire");
        printf("\t\n6. Supprimer les anniversaires en cours");
        printf("\t\n7. Supprimer un anniversaire");
        printf("\t\n8. Quitter");
        printf("\t\n\nVotre choix: ");

        fgets(temp, sizeof(temp), stdin);
        choice = atoi(temp);

        clean_string(temp);

        switch(choice)
        {
            case 1: set_birthday(&ajout);
                    add_birthday(ajout);
                    free(ajout);
                    ajout = NULL;
                break;

            case 2: print_birthdays();
                break;

            case 3: load_birthdays();
                break;

            case 4: save_birthdays();
                break;

            case 5: print_next_birthday();
                break;

            case 6: clean_birthdays();
                break;

            case 7: delete_birthday();
                break;

            default:
                break;
        }

        if( choice != 8 )
        {
            press_enter_to_continue();
            clear_screen();
        }

    }while( choice != 8 );

    clean_birthdays();

    clean_errno();

    return EXIT_SUCCESS;
}