From bc8f587661de49ae7c643dd9ad64ae0bbb219a48 Mon Sep 17 00:00:00 2001 From: JunkJumper Date: Sun, 24 May 2020 19:15:12 +0200 Subject: [PATCH] fix clone @overrired --- src/TD1/point/Point.java | 5 +++-- tests/TD1/point/TestPoint.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/TD1/point/Point.java b/src/TD1/point/Point.java index 0e2f05a..c41f5a5 100644 --- a/src/TD1/point/Point.java +++ b/src/TD1/point/Point.java @@ -52,8 +52,9 @@ public class Point return (this.x == p.x && this.y == p.y); } - public Point clone() { - return this; + @Override + protected Object clone() throws CloneNotSupportedException { + return new Point(this.getX(), this.getY()); } public String displayLocation() { diff --git a/tests/TD1/point/TestPoint.java b/tests/TD1/point/TestPoint.java index fe5cf8e..10c84f1 100644 --- a/tests/TD1/point/TestPoint.java +++ b/tests/TD1/point/TestPoint.java @@ -32,8 +32,8 @@ public class TestPoint { } @Test - public void testClone() { - pT = p1.clone(); + public void testClone() throws CloneNotSupportedException { + pT = (Point) p1.clone(); assertTrue(pT.equals(p1)); }