From d8b812d9dc6a5d496f52ff6763bb5a67c8ae8996 Mon Sep 17 00:00:00 2001 From: Daniel Hladek Date: Mon, 4 Nov 2019 10:36:45 +0100 Subject: [PATCH] initial --- Makefile | 13 +++++++++++++ README.md | 6 ++++-- a_train.c | 18 ++++++++++++++++++ a_train.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ main.c | 17 +++++++++++++++++ 5 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 Makefile create mode 100644 a_train.c create mode 100644 a_train.h create mode 100644 main.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3c2c463 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +CFLAGS= -std=c99 -g -Wall + +all: train + +%.o: %.c + gcc -c -o $@ $< $(CFLAGS) + +train: main.o a_train.o + gcc main.o a_train.o -o train + +clean: + rm *.o train + diff --git a/README.md b/README.md index 9ac048a..6d9dc15 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ -# usaa19cv7 +# Vlak do neba -Šablóna úlohy z siedmeho cvičenia \ No newline at end of file +Šablóna úlohy zo siedmeho cvičenia. + +Úlohu vypracujte do súboru `a_train.c` podľa dokumentácie v súbore `a_train.h`. diff --git a/a_train.c b/a_train.c new file mode 100644 index 0000000..3ecfbc8 --- /dev/null +++ b/a_train.c @@ -0,0 +1,18 @@ +#include "a_train.h" +#include + +struct car* add_car(struct car* first,const char* target) { + return NULL; +} + +void print_train(struct car* first) { +} + +void cancel_train(struct car* first) { +} + + +struct car* clear_train(struct car* first, const char* target) { + return NULL; +} + diff --git a/a_train.h b/a_train.h new file mode 100644 index 0000000..c272268 --- /dev/null +++ b/a_train.h @@ -0,0 +1,50 @@ +#ifndef TRAIN_H +#define TRAIN_H +#define SIZE 100 + +/** + * Jeden vozen vlaku + */ +struct car { + /** + * Nazov cielovej stanice + */ + char value[SIZE]; + /** + * Smenik na dalsi vozen + */ + struct car* next; +}; + +/** + * Prida vozen na koniec vlaku. + * + * @arg nazov cielovej stanice, ktory sa ma priradit novemu voznu. + * @arg kapacita vozna + * @return smernik na zaciatok vlaku. + */ +struct car* add_car(struct car* first,const char* target); + + +/** + * Vypise vsetky vozne vo vlaku + * + * @arg smernik na prvy vozen + */ +void print_train(struct car* first); + +/** + * Zrusenie vsetkych voznov vo vlaku. + * @arg smernik na prvy vozen + */ +void cancel_train(struct car* first); + +/** + * Vyradenie vsetkych voznov, ktorych cielova stanica je target + * + * @arg cielova stanica, ktora sa ma vyradit z vlaku. + * + */ +struct car* clear_train(struct car* first,const char* target); + +#endif // TRAIN_H diff --git a/main.c b/main.c new file mode 100644 index 0000000..d64f05a --- /dev/null +++ b/main.c @@ -0,0 +1,17 @@ +#include "a_train.h" +#include + +// Testovaci subor pre vlak +int main(){ + struct car* train = NULL; + train = add_car(train,"Presov"); + train = add_car(train,"Bratislava"); + train = add_car(train,"Levoca"); + train = add_car(train,"Spiska Nova Ves"); + print_train(train); + clear_train(train,"Levoca"); + print_train(train); + cancel_train(train); + + return 0; +}