2024-11-01 10:00:40 +00:00
|
|
|
#include "a_station.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2024-11-18 17:12:47 +00:00
|
|
|
#include <string.h>
|
2024-11-01 10:00:40 +00:00
|
|
|
|
2024-11-18 17:12:47 +00:00
|
|
|
#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;
|
2024-11-01 10:00:40 +00:00
|
|
|
}
|
2024-11-18 17:12:47 +00:00
|
|
|
|
|
|
|
// 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);
|
2024-11-01 10:00:40 +00:00
|
|
|
}
|
2024-11-18 17:12:47 +00:00
|
|
|
|
|
|
|
printf("Final Statistics:\n");
|
|
|
|
printf("Total number of targets: %d\n", count_targets(station));
|
|
|
|
printf("Total capacity: %d\n", count_capacity(station));
|
2024-11-01 10:00:40 +00:00
|
|
|
}
|
|
|
|
|
2024-11-18 17:12:47 +00:00
|
|
|
int main() {
|
|
|
|
struct station* station = create_station();
|
|
|
|
test_station(station);
|
|
|
|
destroy_station(station);
|
|
|
|
|
|
|
|
return 0;
|
2024-11-01 10:00:40 +00:00
|
|
|
}
|
2024-11-18 17:12:47 +00:00
|
|
|
|