Ejemplo n.º 1
0
bool		update(double dt)
#endif
{
  t_list	*teams;

  if (!(teams = get_teams()))
    return (false);
  foreach_arg_list(teams, update_team, (void*)&dt);
  return (true);
}
vector<Team*> Soccer_league::get_teams()
{
	return get_teams();
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
    /* Prepares globally used data on program start_up */
    int number_of_lines = 0, number_of_matches = 0, number_of_rounds = 0, match_number = 0, user_input = 0;
    char **file_string, early[STR_LEN2], late[STR_LEN2], weekday[STR_LEN];
    match_s *match; /* Note: Array declared, but not allocated or initialized */
    team_s *team; /* Note: Array declared, but not allocated or initialized */

    get_number_of_lines(&number_of_lines);
    get_number_of_matches(number_of_lines, &number_of_matches);
    get_number_of_rounds(number_of_lines, &number_of_rounds);
    file_string = (char **)calloc(number_of_lines,sizeof(char *));
    for(match_number = 0; match_number < number_of_matches; match_number++) {
        file_string[match_number] = (char *)calloc(LINE_LENGTH,sizeof(char));
    }
    read_file(file_string);
    match = (match_s *)calloc(number_of_matches,sizeof(match_s));
    save_file_to_struct(match, file_string, number_of_lines);

    team = (team_s *)calloc(NUMBER_OF_TEAMS,sizeof(team_s));
    get_teams(team, match, number_of_matches);

    /* Run program with user interaction */

    if(argc == 2 && strcmp(argv[1], "--print") == 0) {
        do_all(match, team, number_of_matches, number_of_rounds);
    } else {
        printf("Please input a numner between 1 and 6 to run said program.\nInput 0 to exit the program:\n");
        printf("Input:>> ");
        scanf("%d",&user_input);

        while(user_input != 0) {

            switch (user_input) {
            case 1:
                printf("\nTask one:\n");
                printf("Print all matches that has 7 or more goals total:\n");
                task_one(match, number_of_matches);
                break;
            case 2:
                printf("\nTask two:\n");
                printf("Print the first round with most goals.\n");
                task_two(match, number_of_rounds);
                break;
            case 3:
                printf("\nTask three:\n");
                printf("Get the teams that win more mathces out than home:\n");
                task_three(team);
                break;
            case 4:
                printf("Task four:\n");
                printf("Print the team with fewest spectators when playing home.\n");
                task_four(team);
                break;
            case 5:
                printf("Task five:\n");
                printf("Print the matches in a specific time interval, and sort them by number of goals.\n");
                prompt_time(early, late, weekday);
                task_five(match, number_of_matches, early, late, weekday);
                break;
            case 6:
                printf("Task six:\n");
                printf("Print the result for the end of the season.\n");
                task_six(team, number_of_rounds);
                break;
            default:
                printf("Invalid user input!\n");
                break;
            }

            user_input = 0;

            printf("\nTo perform another task, input a number from 1 - 6.\nTo exit, input 0.\n");
            printf("Input:>> ");
            scanf("%d",&user_input);
        }
    }

    free(match);
    free(team);

    return 0;
}