Skip to content

Commit 516838e

Browse files
committed
Revert "finish (#212)"
This reverts commit 3d72233.
1 parent 3d72233 commit 516838e

File tree

1 file changed

+2
-24
lines changed
  • src/main/java/com/github/hcsp/polymorphism

1 file changed

+2
-24
lines changed

src/main/java/com/github/hcsp/polymorphism/Point.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
import java.io.IOException;
44
import java.util.Arrays;
5-
import java.util.Collection;
6-
import java.util.Collections;
75
import java.util.List;
86

9-
public class Point implements Comparable<Point> {
7+
public class Point {
108

119
private final int x;
1210
private final int y;
13-
1411
// 代表笛卡尔坐标系中的一个点
1512
public Point(int x, int y) {
1613
this.x = x;
@@ -56,10 +53,7 @@ public String toString() {
5653

5754
// 按照先x再y,从小到大的顺序排序
5855
// 例如排序后的结果应该是 (-1, 1) (1, -1) (2, -1) (2, 0) (2, 1)
59-
public static List<Point> sort(List<Point> points) {
60-
Collections.sort(points);
61-
return points;
62-
}
56+
public static List<Point> sort(List<Point> points) {}
6357

6458
public static void main(String[] args) throws IOException {
6559
List<Point> points =
@@ -71,20 +65,4 @@ public static void main(String[] args) throws IOException {
7165
new Point(2, -1));
7266
System.out.println(Point.sort(points));
7367
}
74-
75-
@Override
76-
public int compareTo(Point that) {
77-
if (this.x < that.x) {
78-
return -1;
79-
} else if (this.x > that.x) {
80-
return 1;
81-
}
82-
83-
if (this.y < that.y) {
84-
return -1;
85-
} else if (this.y > that.y) {
86-
return 1;
87-
}
88-
return 0;
89-
}
9068
}

0 commit comments

Comments
 (0)