Exemple #1
0
int main(void) {
    printf("Welcome to championship whack-a-mole!\nType \"help\" for more information.\n");
  
    char cmd[NAME_SIZE+1]={0};
    Team* selectedTeam;
    ScoreboardList = NULL;
    ReadTeams();

    while(true) {
        printf("\n>>> ");
        do {
            fflush(stdout);
        } while ( !readString(cmd, NAME_SIZE) );
        printf("\n");

        if ( ! strcmp(cmd, "q") || ! strcmp(cmd, "quit") ) {
            printf("Bye bye!");
            break;
        }
        else if ( !strncmp(cmd, "SHOW ", 5) ) {
            if ( !strcmp(&cmd[5], "TEAMS") ) { // 5 = strlen("SHOW ");
                LastGameList = NULL;
                ShowGames();
            } else if ( (selectedTeam = getTeamFromInput(&cmd[5])) != NULL ){
                TeamUpdateGameListCache(selectedTeam, NULL);
                LastGameList = selectedTeam->gameList;
                printf("TEAM: %s\n", selectedTeam->name); // FIXME: TESTING
                ShowGames();
            } else
                goto wrong_command;
        }
        else if ( !strcmp(cmd, "teams") ) {
            ListTeams();
        }
        else if ( !strncmp(cmd, "add", 3) ) {
            NewGame(&cmd[4]); // 4 = strlen("add ")
        }
        else if ( !strncmp(cmd, "del", 3) ) {
            DeleteGame(&cmd[3]); // 3 = strlen("del")
        }
        else if ( !strcmp(cmd, "scores") ) {
            ShowScoreboard();
        }
        else if ( !strcmp(cmd, "help") ) {
            showHelp();
        }
        else {
            wrong_command:
            printf("Unrecognized command.\n");
        }

    }

    return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
	JaimeChapinal me;

	me.SetEmail("*****@*****.**");
	me.SetWeb("www.jaimechapinal.com");
	me.SetTelephone("678-97-57-76");

	me.SetStudies();
	me.SetPublications();
	me.SetJobs();
	me.SetGames();
	me.SetSkills();

	ShowTitle(me);

	bool bExit = false;
	int iOption = -1;
	while (!bExit)
	{
		ShowMainMenu();	
		iOption = ReadInput();
		switch (iOption)
		{
			case 1:	//Personal data
				ShowPersonalData(me);
			break;
			case 2:	//Studies data
				ShowStudiesData(me.GetStudies());
			break;
			case 3: //Professional data
				ShowPublications(me.GetPublications());
			break;
			case 4: //Professional data
				ShowProfessionalData(me.GetJobs());
			break;
			case 5:	//Games
				ShowGames(me.GetGames());
			break;
			case 6:	//Skills
				ShowSkills(me.GetSkills());
			break;
			case 0: //Exit
				bExit = true;
			break;
			default:
				std::cout << "Invalid option. Please, try again. " << std::endl;
				std::cout << std::endl;
			break;
		}
	}
	std::cout << std::endl;
	std::cout << "Thanks for your time! =) " << std::endl;
	getch();
	return 0;
}