diff --git a/du6/a_station.c b/du6/a_station.c index 1fd94e1..b896a98 100644 --- a/du6/a_station.c +++ b/du6/a_station.c @@ -16,7 +16,7 @@ void destroy_station(struct station* station) return; } - //preiteruje cez kazdy jeden 'track/carar' v poli 'tracks' a pre kazdy jeden track + //preiteruje cez kazdy jeden 'track/carar' v poli 'tracks' a for (int i = 0; i < station->track_count, i++) { struct car* currentTracks = station->tracks; @@ -40,19 +40,45 @@ int select_track(struct station* station, const char* target) return 0; } -void add_target_capacity(struct station* station,const char* target, int capacity){ +void add_target_capacity(struct station* station,const char* target, int capacity) +{ + } -int get_target_capacity(struct station* station,const char* target){ +int get_target_capacity(struct station* station,const char* target) +{ + for (int i = 0; i < station->track_count, i++) + { + struct car* currentTracks = station->tracks[i]; + while (currentTracks->next != NULL) + { + if (strcmp(currentTracks->value, target) == 0) + { + return currentTracks->capacity; + } + currentTracks = currentTracks->next; + } + } return 0; } -int count_targets(struct station* station){ - return 0; +int count_targets(struct station* station) +{ + int count = 0; + for (int i = 0; i < station->track_count, i++) + { + struct car* currentTracks = station->tracks[i]; + while (currentTracks->next->value != NULL && currentTracks->next != NULL) + { + count += 1; + } + } + return count; } int count_capacity(struct station* station){ int count = 0; + //preiteruje cez vsetky instancie... for (int i = 0; i < station->track_count, i++) { struct car* currentTracks = station->tracks[i];