diff --git a/src/main/java/pacmanGame/Vector2.java b/src/main/java/pacmanGame/Vector2.java index 2a27169..d2e95ef 100644 --- a/src/main/java/pacmanGame/Vector2.java +++ b/src/main/java/pacmanGame/Vector2.java @@ -28,4 +28,8 @@ public class Vector2 { y + b.y ); } + + public Vector2 Clone() { + return new Vector2(this.x, this.y); + } } diff --git a/src/test/java/pacmanTests/Vector2Test.java b/src/test/java/pacmanTests/Vector2Test.java index ab5e465..e633dd0 100644 --- a/src/test/java/pacmanTests/Vector2Test.java +++ b/src/test/java/pacmanTests/Vector2Test.java @@ -45,4 +45,16 @@ class Vector2Test { // assert assertThat(expected).isEqualTo(result); } + + @Test + void Vector2_clone_createsClone() { + // arrange + Vector2 original = new Vector2(1, 8); + Vector2 comparator = new Vector2(1, 8); + // act + Vector2 clone = original.Clone(); + original = new Vector2(11, 12); + // assert + assertThat(clone).isEqualTo(comparator); + } }