diff --git a/cv6/a_station.o b/cv6/a_station.o deleted file mode 100644 index eb74371..0000000 Binary files a/cv6/a_station.o and /dev/null differ diff --git a/cv6/main.c b/cv6/main.c index a909625..dee0e23 100644 --- a/cv6/main.c +++ b/cv6/main.c @@ -1,41 +1,54 @@ #include "a_station.h" #include -#include #include +#include -void print_station(struct station* station){ - // Vypise celu stanicu - printf("station>>>\n"); - // Prechadza vsetky trate - for (int i = 0 ; i< station->track_count; i++){ - struct car* start = station->tracks[i]; - struct car* this = start; - // Prechadza vsetky vozne - while(this != NULL){ - printf("%s %d -> ",this->value,this->capacity); - this=this->next; +#define MAX_INPUT 100 + +void test_station(struct station* station) { + char station_name[MAX_INPUT]; + int capacity; + + printf("Enter station name and capacity (or 'exit' to stop):\n"); + + while (1) { + printf("Station name: "); + if (!fgets(station_name, MAX_INPUT, stdin)) break; + + // Remove trailing newline + station_name[strcspn(station_name, "\n")] = '\0'; + + if (strcmp(station_name, "exit") == 0) break; + + printf("Capacity: "); + if (scanf("%d", &capacity) != 1) { + printf("Invalid input. Try again.\n"); + while (getchar() != '\n'); // Clear input buffer + continue; } - printf("NULL\n"); + + // Clear input buffer + while (getchar() != '\n'); + + add_target_capacity(station, station_name, capacity); + + int track = select_track(station, station_name); + printf("Track for %s: %d\n", station_name, track); + + int current_capacity = get_target_capacity(station, station_name); + printf("Current capacity to %s: %d\n\n", station_name, current_capacity); } - printf("<<