-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlace.java
More file actions
74 lines (61 loc) · 1.82 KB
/
Place.java
File metadata and controls
74 lines (61 loc) · 1.82 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//Author: Dennis Eriksson Berg
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;
public abstract class Place extends Polygon {
private Position newPosition;
private String category;
private String name;
private boolean isMarked = false;
public Place(Position xy, String name, String category) {
newPosition = xy;
this.name = name;
this.category = category;
xy.setPlace(this);
setColor(category);
getPoints().setAll(newPosition.getX(), newPosition.getY(), newPosition.getX() - 15, newPosition.getY() - 30, newPosition.getX() + 15, newPosition.getY() - 30);
relocate(newPosition.getX() - 15, newPosition.getY() - 30);
}
protected void setColor(String category) {
if (category.equals("Bus")) {
setFill(Color.RED);
}
if (category.equals("Underground")) {
setFill(Color.BLUE);
}
if (category.equals("Train")) {
setFill(Color.GREEN);
}
if (category.equals("None")) {
setFill(Color.BLACK);
}
}
public String getCategory() {
return category;
}
public String getName() {
return name;
}
public void setMarked(boolean b) {
isMarked = b;
}
public boolean getMarked() {
return isMarked;
}
//Skapa funktionalitet på hashtable
public Position getNewPosition() {
return newPosition;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Place) {
Place place = (Place) obj;
return newPosition.equals(place.getNewPosition());
}
return false;
}
public int hashCode() {
int x = (int) newPosition.getX();
int y = (int) newPosition.getY();
return x * 10000 + y;
}
}