From 7c4662b3222b7c50fdf8a3e553548d5c67f40a46 Mon Sep 17 00:00:00 2001 From: Samuel Oberhofer Date: Mon, 23 May 2022 20:58:19 +0200 Subject: [PATCH] Add Sortiment --- Uebung 1/Makefile | 2 +- Uebung 1/Sortiment.cpp | 9 +++++++++ Uebung 1/Sortiment.h | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Uebung 1/Sortiment.cpp create mode 100644 Uebung 1/Sortiment.h diff --git a/Uebung 1/Makefile b/Uebung 1/Makefile index 0462596..80ecb9d 100644 --- a/Uebung 1/Makefile +++ b/Uebung 1/Makefile @@ -4,7 +4,7 @@ BINARY = prototyp # Name of the binary for Release FINAL = prototyp # Object files -OBJS = main.o Machine.o MachineProductA.o MachineProductB.o Factory.o ##Product.o +OBJS = Sortiment.o # Compiler flags CFLAGS = -Werror -Wall -std=c++17 -fsanitize=address,undefined -g # Linker flags diff --git a/Uebung 1/Sortiment.cpp b/Uebung 1/Sortiment.cpp new file mode 100644 index 0000000..c78282a --- /dev/null +++ b/Uebung 1/Sortiment.cpp @@ -0,0 +1,9 @@ +#include "Sortiment.h" + +void Sortiment::addWare(Ware *ware) { + for (int i = 0; i < 10; i++) { + if (this->waren[i] == nullptr) { + this->waren[i] = ware; + } + } +} \ No newline at end of file diff --git a/Uebung 1/Sortiment.h b/Uebung 1/Sortiment.h new file mode 100644 index 0000000..ce3213c --- /dev/null +++ b/Uebung 1/Sortiment.h @@ -0,0 +1,16 @@ +#pragma once + +class Ware; + +class Sortiment { +private: + Ware *waren[10]; + +public: + void addWare(Ware *ware); + Sortiment() { + for (int i = 0; i < 10;) { + waren[i] = nullptr; + } + } +}; \ No newline at end of file