2024-10-30 12:03:56 +00:00
|
|
|
|
2024-10-30 08:33:40 +00:00
|
|
|
#include <stdio.h>
|
2024-10-30 12:03:56 +00:00
|
|
|
#include <stdlib.h>
|
2024-10-30 08:33:40 +00:00
|
|
|
#include "a_station.h"
|
2024-10-30 12:03:56 +00:00
|
|
|
#include <string.h>
|
2024-10-30 08:33:40 +00:00
|
|
|
|
|
|
|
int main() {
|
2024-10-30 08:39:52 +00:00
|
|
|
// Vytvorenie stanice
|
|
|
|
struct station* moja_stanica = create_station();
|
|
|
|
if (moja_stanica == NULL) {
|
|
|
|
printf("Chyba pri vytváraní stanice.\n");
|
2024-10-30 08:33:40 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-10-30 12:03:56 +00:00
|
|
|
// Načítanie údajov zo súboru
|
|
|
|
load_from_file(moja_stanica);
|
|
|
|
|
|
|
|
// Cyklus pre zadávanie nových záznamov
|
|
|
|
char target[TARGET_SIZE];
|
|
|
|
int capacity;
|
|
|
|
while (1) {
|
|
|
|
printf("Zadajte názov stanice (alebo 'exit' pre ukončenie): ");
|
|
|
|
scanf("%s", target);
|
|
|
|
if (strcmp(target, "exit") == 0) {
|
|
|
|
break; // Ukončiť cyklus
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Zadajte počet cestujúcich: ");
|
|
|
|
scanf("%d", &capacity);
|
|
|
|
add_target_capacity(moja_stanica, target, capacity);
|
|
|
|
}
|
2024-10-30 08:33:40 +00:00
|
|
|
|
2024-10-30 12:03:56 +00:00
|
|
|
// Výstup informácií o staniciach
|
|
|
|
printf("Uložené údaje:\n");
|
|
|
|
for (int i = 0; i < moja_stanica->track_count; i++) {
|
|
|
|
struct car* current = moja_stanica->tracks[i];
|
|
|
|
while (current != NULL) {
|
|
|
|
printf("Stanica: %s, Cestujúcich: %d\n", current->value, current->capacity);
|
|
|
|
current = current->next;
|
|
|
|
}
|
|
|
|
}
|
2024-10-30 08:33:40 +00:00
|
|
|
|
2024-10-30 12:03:56 +00:00
|
|
|
// Uloženie údajov do súboru pred ukončením
|
|
|
|
save_to_file(moja_stanica);
|
2024-10-30 08:33:40 +00:00
|
|
|
|
2024-10-30 08:39:52 +00:00
|
|
|
// Uvoľnenie pamäte
|
|
|
|
destroy_station(moja_stanica);
|
2024-10-30 08:33:40 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2024-10-30 12:03:56 +00:00
|
|
|
|