Opdracht 1
This commit is contained in:
parent
9011cb3569
commit
4fe07a69f4
7
.vscode/launch.json
vendored
Normal file
7
.vscode/launch.json
vendored
Normal file
@ -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": []
|
||||
}
|
48
.vscode/tasks.json
vendored
Normal file
48
.vscode/tasks.json
vendored
Normal file
@ -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"
|
||||
}
|
5
Opdracht_1/Interface.cpp
Normal file
5
Opdracht_1/Interface.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "Interface.h"
|
||||
|
||||
Interface::Interface(){
|
||||
|
||||
}
|
14
Opdracht_1/Interface.h
Normal file
14
Opdracht_1/Interface.h
Normal file
@ -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
|
22
Opdracht_1/Positie.cpp
Normal file
22
Opdracht_1/Positie.cpp
Normal file
@ -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;
|
||||
}
|
18
Opdracht_1/Positie.h
Normal file
18
Opdracht_1/Positie.h
Normal file
@ -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
|
18
Opdracht_1/Robot.cpp
Normal file
18
Opdracht_1/Robot.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "Robot.h"
|
||||
#include "Positie.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
Robot::Robot(Interface *Pos): P(Pos){
|
||||
|
||||
}
|
||||
|
||||
Robot::~Robot(){}
|
||||
|
||||
void Robot::run(){
|
||||
P->move(10,20);
|
||||
}
|
||||
|
||||
void Robot::show(){
|
||||
std::cout << P->x() << P->y();
|
||||
}
|
18
Opdracht_1/Robot.h
Normal file
18
Opdracht_1/Robot.h
Normal file
@ -0,0 +1,18 @@
|
||||
class Positie;
|
||||
class Interface;
|
||||
|
||||
#ifndef Robot_H
|
||||
#define Robot_H
|
||||
|
||||
class Robot{
|
||||
private:
|
||||
Interface *P;
|
||||
//Positie *P = dynamic_cast<Positie*>(I);
|
||||
public:
|
||||
Robot (Interface*);
|
||||
virtual ~Robot();
|
||||
void run();
|
||||
void show();
|
||||
};
|
||||
|
||||
#endif
|
43
Opdracht_1/class.drawio
Normal file
43
Opdracht_1/class.drawio
Normal file
@ -0,0 +1,43 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="hUXen1-xG9g13vyYE9lk" name="Page-1">
|
||||
<mxGraphModel dx="1186" dy="652" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="5" value="Positie" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="170" y="320" width="140" height="150" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="6" value="- x : Int<br>- y : int" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="5">
|
||||
<mxGeometry y="30" width="140" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="7" value="+ move (int, int)<br>+ x : int<br>+ y : int" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="5">
|
||||
<mxGeometry y="60" width="140" height="90" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="9" value="Interface" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="170" y="90" width="140" height="110" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="10" value="+ move (int, int)<br>+ x : int<br>+ y : int" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="9">
|
||||
<mxGeometry y="30" width="140" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="13" value="" style="endArrow=diamondThin;endFill=0;endSize=24;html=1;" edge="1" parent="1" target="10">
|
||||
<mxGeometry width="160" relative="1" as="geometry">
|
||||
<mxPoint x="240" y="320" as="sourcePoint"/>
|
||||
<mxPoint x="240" y="210" as="targetPoint"/>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="16" value="Robot" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="480" y="120" width="140" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="17" value="+ show<br>+ run" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="16">
|
||||
<mxGeometry y="30" width="140" height="50" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="20" value="" style="endArrow=classic;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" target="10">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="480" y="160" as="sourcePoint"/>
|
||||
<mxPoint x="425" y="120" as="targetPoint"/>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
10
Opdracht_1/main.cpp
Normal file
10
Opdracht_1/main.cpp
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user