diff options
author | Camil Staps | 2015-04-18 13:44:44 +0200 |
---|---|---|
committer | Camil Staps | 2015-04-18 13:44:44 +0200 |
commit | 6a44b074f0169a1b0f9e92347af929c5e471746e (patch) | |
tree | ae5663fe7c69881bf4ecfedbef99c2505f8ec964 /Week4 Drawing loipes/src/oo15loipe/Punt.java | |
parent | Added copyright to docs (diff) |
Reorganised projects
Diffstat (limited to 'Week4 Drawing loipes/src/oo15loipe/Punt.java')
-rw-r--r-- | Week4 Drawing loipes/src/oo15loipe/Punt.java | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/Week4 Drawing loipes/src/oo15loipe/Punt.java b/Week4 Drawing loipes/src/oo15loipe/Punt.java new file mode 100644 index 0000000..2c94f1f --- /dev/null +++ b/Week4 Drawing loipes/src/oo15loipe/Punt.java @@ -0,0 +1,73 @@ +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 + ")"; + } +} |