diff options
Diffstat (limited to 'week-2')
-rw-r--r-- | week-2/Driehoek.cpp | 15 | ||||
-rw-r--r-- | week-2/Driehoek.h | 13 | ||||
-rw-r--r-- | week-2/Rechthoek.cpp | 14 | ||||
-rw-r--r-- | week-2/Rechthoek.h | 13 | ||||
-rw-r--r-- | week-2/Vorm.cpp | 13 | ||||
-rw-r--r-- | week-2/Vorm.h | 9 | ||||
-rw-r--r-- | week-2/main.cpp | 21 | ||||
-rw-r--r-- | week-2/makefile | 24 |
8 files changed, 122 insertions, 0 deletions
diff --git a/week-2/Driehoek.cpp b/week-2/Driehoek.cpp new file mode 100644 index 0000000..1c1323c --- /dev/null +++ b/week-2/Driehoek.cpp @@ -0,0 +1,15 @@ +#include "Driehoek.h" + +Driehoek::Driehoek(double b, double h) { + breedte = b; + hoogte = h; +} + +double Driehoek::getSomGraden() { + return 180; +} + +double Driehoek::getOppervlakte() { + return breedte * hoogte * 0.5f; +} + diff --git a/week-2/Driehoek.h b/week-2/Driehoek.h new file mode 100644 index 0000000..f8a3a37 --- /dev/null +++ b/week-2/Driehoek.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Vorm.h" + +class Driehoek : public Vorm { + public: + Driehoek(double breedte, double hoogte); + virtual double getOppervlakte(); + virtual double getSomGraden(); + private: + double breedte; + double hoogte; +}; diff --git a/week-2/Rechthoek.cpp b/week-2/Rechthoek.cpp new file mode 100644 index 0000000..1f7b313 --- /dev/null +++ b/week-2/Rechthoek.cpp @@ -0,0 +1,14 @@ +#include "Rechthoek.h" + +Rechthoek::Rechthoek(double b, double h) { + breedte = b; + hoogte = h; +} + +double Rechthoek::getSomGraden() { + return 360; +} + +double Rechthoek::getOppervlakte() { + return breedte * hoogte; +} diff --git a/week-2/Rechthoek.h b/week-2/Rechthoek.h new file mode 100644 index 0000000..4f526f9 --- /dev/null +++ b/week-2/Rechthoek.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Vorm.h" + +class Rechthoek : public Vorm { + public: + Rechthoek(double breedte, double hoogte); + virtual double getSomGraden(); + virtual double getOppervlakte(); + private: + double breedte; + double hoogte; +}; diff --git a/week-2/Vorm.cpp b/week-2/Vorm.cpp new file mode 100644 index 0000000..c919d08 --- /dev/null +++ b/week-2/Vorm.cpp @@ -0,0 +1,13 @@ +#include "Vorm.h" + +Vorm::Vorm() { + return; +} + +double Vorm::getOppervlakte() { + return 0; +} + +double Vorm::getSomGraden() { + return 0; +} diff --git a/week-2/Vorm.h b/week-2/Vorm.h new file mode 100644 index 0000000..17cf486 --- /dev/null +++ b/week-2/Vorm.h @@ -0,0 +1,9 @@ +#pragma once + +class Vorm { + public: + Vorm(); + virtual double getOppervlakte(); + virtual double getSomGraden(); +}; + diff --git a/week-2/main.cpp b/week-2/main.cpp new file mode 100644 index 0000000..69db85b --- /dev/null +++ b/week-2/main.cpp @@ -0,0 +1,21 @@ +/*
+ * Do not adapt this file!!!
+ */
+#include "Driehoek.h"
+#include "Rechthoek.h"
+
+#include <iostream>
+
+int main()
+{
+ Vorm *driehoek = new Driehoek( 6.0, 8.0 );
+ Vorm *rechthoek = new Rechthoek( 6.0, 8.0 );
+
+ std::cout << driehoek ->getOppervlakte() << " " << driehoek ->getSomGraden() << std::endl;
+ std::cout << rechthoek->getOppervlakte() << " " << rechthoek->getSomGraden() << std::endl;
+
+ delete driehoek;
+ delete rechthoek;
+
+ return 0;
+}
diff --git a/week-2/makefile b/week-2/makefile new file mode 100644 index 0000000..3b71b5b --- /dev/null +++ b/week-2/makefile @@ -0,0 +1,24 @@ +CC = gcc +LD = gcc +RM = rm -f +TARGET = main + +LFLAGS += -lstdc++ + +SRCS := $(wildcard *.cpp) +OBJS := $(patsubst %.cpp,%.o, $(SRCS)) + +all: main + +%.o: %.cpp + $(CC) -c $(CFLAGS) $< -o $@ + +$(TARGET): $(OBJS) + $(LD) $^ $(LFLAGS) -o $@ + +clean: + $(RM) $(TARGET) $(OBJS) + +compile_commands: clean + compiledb make + |