diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5c7247b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,7 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..889478e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,48 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: cl.exe build active file", + "command": "cl.exe", + "args": [ + "/Zi", + "/EHsc", + "/nologo", + "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe", + "${file}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$msCompile" + ], + "group": "build", + "detail": "Task generated by Debugger." + }, + { + "type": "cppbuild", + "label": "C/C++: g++.exe build active file", + "command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/Opdracht_1/Interface.cpp b/Opdracht_1/Interface.cpp new file mode 100644 index 0000000..abceb10 --- /dev/null +++ b/Opdracht_1/Interface.cpp @@ -0,0 +1,5 @@ +#include "Interface.h" + +Interface::Interface(){ + +} \ No newline at end of file diff --git a/Opdracht_1/Interface.h b/Opdracht_1/Interface.h new file mode 100644 index 0000000..e0391b6 --- /dev/null +++ b/Opdracht_1/Interface.h @@ -0,0 +1,14 @@ +#ifndef INTERFACE_H +#define INTERFACE_H + +class Interface +{ +private: +public: +Interface(); +virtual ~Interface(){}; +virtual int x() = 0; +virtual int y() = 0; +virtual void move(int, int) = 0; +}; +#endif \ No newline at end of file diff --git a/Opdracht_1/Positie.cpp b/Opdracht_1/Positie.cpp new file mode 100644 index 0000000..f72c8e7 --- /dev/null +++ b/Opdracht_1/Positie.cpp @@ -0,0 +1,22 @@ +#include "Positie.h" + +Positie::Positie(int x, int y): X(x), Y(y){ + +} + +Positie::~Positie(){ + +} + +int Positie::x(){ + return X; +} + +int Positie::y(){ + return Y; +} + +void Positie::move(int dx, int dy){ + X = X+dx; + Y = Y+dy; +} \ No newline at end of file diff --git a/Opdracht_1/Positie.h b/Opdracht_1/Positie.h new file mode 100644 index 0000000..a736854 --- /dev/null +++ b/Opdracht_1/Positie.h @@ -0,0 +1,18 @@ +#include "Interface.h" + +#ifndef Positie_H +#define Positie_H + +class Positie : public Interface{ +private: + int X; + int Y; +public: + Positie (int, int); + ~Positie(); + virtual int x(); + virtual int y(); + virtual void move (int, int); +}; + +#endif \ No newline at end of file diff --git a/Opdracht_1/Robot.cpp b/Opdracht_1/Robot.cpp new file mode 100644 index 0000000..394bb79 --- /dev/null +++ b/Opdracht_1/Robot.cpp @@ -0,0 +1,18 @@ +#include "Robot.h" +#include "Positie.h" + +#include + +Robot::Robot(Interface *Pos): P(Pos){ + +} + +Robot::~Robot(){} + +void Robot::run(){ + P->move(10,20); +} + +void Robot::show(){ + std::cout << P->x() << P->y(); +} \ No newline at end of file diff --git a/Opdracht_1/Robot.h b/Opdracht_1/Robot.h new file mode 100644 index 0000000..bb7dd56 --- /dev/null +++ b/Opdracht_1/Robot.h @@ -0,0 +1,18 @@ +class Positie; +class Interface; + +#ifndef Robot_H +#define Robot_H + +class Robot{ +private: +Interface *P; +//Positie *P = dynamic_cast(I); +public: + Robot (Interface*); + virtual ~Robot(); + void run(); + void show(); +}; + +#endif \ No newline at end of file diff --git a/Opdracht_1/class.drawio b/Opdracht_1/class.drawio new file mode 100644 index 0000000..047a98c --- /dev/null +++ b/Opdracht_1/class.drawio @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Opdracht_1/main.cpp b/Opdracht_1/main.cpp new file mode 100644 index 0000000..c8c141d --- /dev/null +++ b/Opdracht_1/main.cpp @@ -0,0 +1,10 @@ +#include "Positie.h" +#include "Robot.h" + +int main ( ){ + Positie P ( 5, 10 ); + Robot R ( &P ); + R.run ( ); + R.show ( ); + return 0; +} \ No newline at end of file