aboutsummaryrefslogtreecommitdiff
path: root/Week4/src/oo15loipe
diff options
context:
space:
mode:
authorCamil Staps2015-02-26 16:05:54 +0100
committerCamil Staps2015-02-26 16:05:54 +0100
commitbca99208b92d3f0afff63ecfa665a38ed8673b6d (patch)
tree8723bedd73a97a8fadd5f9f358c16d67574971e8 /Week4/src/oo15loipe
parentMerge branch 'master' into camil (diff)
x
Diffstat (limited to 'Week4/src/oo15loipe')
-rw-r--r--Week4/src/oo15loipe/Punt.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/Week4/src/oo15loipe/Punt.java b/Week4/src/oo15loipe/Punt.java
new file mode 100644
index 0000000..1939c45
--- /dev/null
+++ b/Week4/src/oo15loipe/Punt.java
@@ -0,0 +1,77 @@
+package oo15loipe;
+
+/**
+ * Een Punt in 2D
+ * @author pieter koopman
+ */
+
+public class Punt {
+ private int x, y;
+
+ /**
+ * de gewone constructor
+ * @param i: x
+ * @param j; y
+ */
+ public Punt(int i, int j) {
+ x = i;
+ y = j;
+ }
+
+ /**
+ * copy constructor
+ * @param p
+ */
+ public Punt (Punt p) {
+ if (p != null) {
+ x = p.x;
+ y = p.y;
+ } else {
+ x = y = 0;
+ }
+ }
+
+ /**
+ * getter voor x
+ * @return x
+ */
+ public int getX (){
+ return x;
+ }
+
+ /**
+ * getter voor y
+ * @return y
+ */
+ public int getY (){
+ return y;
+ }
+
+ /**
+ * equals methode vergelijkt x en y
+ * @param o
+ * @return
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o != null && o instanceof Punt) {
+ Punt p = (Punt) o;
+ return x == p.x && y == p.y;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Punt naar String conversie
+ * @return Strin met waarde van x en y
+ */
+ @Override
+ public String toString () {
+ return "(" + x + "," + y + ")";
+ }
+
+ public Punt add(Punt plus) {
+ return new Punt(x + plus.getX(), y + plus.getY());
+ }
+}