Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

Commit

Permalink
segmention fault has been fixed and now the project works well
Browse files Browse the repository at this point in the history
  • Loading branch information
mreza-kiani committed Dec 1, 2017
1 parent 93ecd2c commit 92c84f2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions cup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void Cup::simulate(){
while(in_cup_teams.size() != 1){
Round new_round(in_cup_teams, round_number);
new_round.simulate();
rounds.push_back(new_round);

in_cup_teams = get_in_cup_teams();
round_number++;
Expand Down
2 changes: 1 addition & 1 deletion leg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void Leg::simulate() {
}

int Leg::get_num_of_goals(int home_attack, int home_midfield, int away_deffend, int away_midfield) {
float result = (home_attack * home_midfield) / (away_midfield * away_deffend);
float result = (float)(home_attack * home_midfield) / (float)(away_midfield * away_deffend);
return floor(3 * result * sqrt(result));
}

Expand Down
5 changes: 4 additions & 1 deletion match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using namespace std;

Match::Match(Team* home, Team* away, int number)
: first_leg(home, away), second_leg(away, home), match_number(number), first_team(home), second_team(away) {}
: first_leg(home, away), second_leg(away, home), match_number(number), first_team(home), second_team(away) {
winner = NULL;
}

void Match::simulate() {
first_leg.simulate();
Expand Down Expand Up @@ -46,6 +48,7 @@ void Match::penalty_time() {
first_team->set_participation_status(false);
winner = second_team;
}

}

void Match::print_match() {
Expand Down
3 changes: 2 additions & 1 deletion round.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ void Round::simulate() {

void Round::print_round() {
cout << "Round " << round_number << endl;
for (int i = 0; i < matches.size() ; i++ )
for (int i = 0; i < matches.size() ; i++ ){
matches[i].print_match();
}
}

void Round::print_team_result(Team* team) {
Expand Down

0 comments on commit 92c84f2

Please sign in to comment.