Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/main/java/coordinate/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
import java.util.Objects;

public class Point {
private int x;
private int y;

public Point(int x, int y) throws IllegalArgumentException {
if (x < 0 || x > 24 || y < 0 || y > 24)
throw new IllegalArgumentException("x와 y값은 0초과 24미만 값이어야 합니다.");
this.x = x;
this.y = y;
private PointNumber x;
private PointNumber y;

// public Point(PointNumber x, PointNumber y) {
// this.x = x;
// this.y = y;
// }

public Point(int x, int y) {
this.x = new PointNumber(x);
this.y = new PointNumber(y);
}

public double calculatorLength(Point point) {
return Math.sqrt(Math.pow(this.x - point.x, 2) + Math.pow(this.y - point.y, 2));
return Math.sqrt(Math.pow(this.x.getNumber() - point.x.getNumber(), 2) + Math.pow(this.y.getNumber() - point.y.getNumber(), 2));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x.pow(point.x)와 같이 구현해도 되지 않을까?

}

public Boolean matchX(Point point) {
Expand All @@ -26,7 +29,7 @@ public Boolean matchY(Point point) {
}

public Boolean matchDot(int x, int y) {
return this.x * 3 == x && this.y == y;
return this.x.getNumber() * 3 == x && this.y.getNumber() == y;
}

@Override
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/coordinate/PointNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package coordinate;

public class PointNumber {
private int number;

public PointNumber(int number) throws IllegalArgumentException {
if (number < 0 || number > 24)
throw new IllegalArgumentException("입력 좌표값은 0초과 24미만 값이어야 합니다.");
this.number = number;
}

public int getNumber() {
return number;
}
}
1 change: 1 addition & 0 deletions src/main/java/coordinate/figure/Rectangle.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public class Rectangle extends Figure {
public Rectangle(List<Point> points) {
super(points);
checkRectangle();
}

void checkRectangle() throws IllegalArgumentException {
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/lotto/LottoGameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.Test;

import java.util.StringTokenizer;

import static org.assertj.core.api.Assertions.assertThat;

public class LottoGameTest {
Expand Down