Add Sortiment

This commit is contained in:
Samuel Oberhofer 2022-05-23 20:58:19 +02:00
parent ace7da5f91
commit 7c4662b322
3 changed files with 26 additions and 1 deletions

View File

@ -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

9
Uebung 1/Sortiment.cpp Normal file
View File

@ -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;
}
}
}

16
Uebung 1/Sortiment.h Normal file
View File

@ -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;
}
}
};