-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPoint.java
50 lines (43 loc) · 1.09 KB
/
Point.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package hello;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import hello.Main.cell_click_event;
import hello.pages.s1controller;
import javafx.fxml.FXMLLoader;
import javafx.scene.Group;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
public class Point
{
private static Map<String, Point> instances = new HashMap<String, Point>();
private final int x, y; // immutable
private Point(int x, int y)
{
this.x = x;
this.y = y;
}
public static Point getInstance(int x, int y)
{
String key = x + ", " + y;
if (!instances.containsKey(key))
{
instances.put(key, new Point(x, y));
}
return instances.get(key);
}
public static boolean is_Present (int x,int y)
{
String key = x + ", " + y;
return (instances.containsKey(key));
}
public int getX() { return x; }
public int getY() { return y; }
public String toString()
{
return "(" + x + ", " + y + ")";
}
}