This commit is contained in:
Bohdan Kapliuk 2024-11-03 20:01:33 +02:00
parent 4253b35109
commit 5d4e3c95b5

View File

@ -61,14 +61,42 @@ void add_target_capacity(struct station* station, const char* target, int capaci
int get_target_capacity(struct station* station, const char* target) {
int track_index = select_track(station, target);
struct car* current = station->tracks[track_index];
while (current) {
if (strcmp(current->value, target) == 0) {
return current->capacity;
}
current = current->next;
}
return 0;
}
int count_targets(struct station* station) {
return 0;
int count = 0;
for (int i = 0; i < station->track_count; i++) {
struct car* current = station->tracks[i];
while (current) {
count++;
current = current->next;
}
}
return count;
}
int count_capacity(struct station* station) {
return 0;
int total_capacity = 0;
for (int i = 0; i < station->track_count; i++) {
struct car* current = station->tracks[i];
while (current) {
total_capacity += current->capacity;
current = current->next;
}
}
return total_capacity;
}