diff --git a/cv6/a_station.c b/cv6/a_station.c index 9796ce3..7f0529a 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -50,6 +50,22 @@ int select_track(struct station* station, const char* target){ } void add_target_capacity(struct station* station,const char* target, int capacity){ +int i = select_track(station,target); + struct car* slot = station->tracks[i]; + if(station->tracks[i]==NULL){ + struct car* newCar = malloc(sizeof(struct car)); + strcpy(newCar->value,target); + newCar->capacity=capacity; + newCar->next=slot; + station->tracks[i]=newCar; + } + while (slot!=NULL) + { + if(strcmp(slot->value,target)==0){ + slot->capacity +=capacity; + } + slot=slot->next; + } } int get_target_capacity(struct station* station,const char* target){