This repository was archived by the owner on Jul 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.java
More file actions
148 lines (135 loc) · 2.46 KB
/
Point.java
File metadata and controls
148 lines (135 loc) · 2.46 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
The Gang
****************************
Marcin Sek 18254187
Jordan Marshall 18256716
Ademide Adenuga 18220258
Rioghan Lowry 18226531
****************************
*/
public class Point
{
private int row;
private int col;
private int g;
private int score;
private Point parent;
/**
* Point Constructor
*
* @param row the index of the row in which the point is
* @param col the index of the col in which the point is
*/
public Point(int row, int col)
{
this.row = row;
this.col = col;
this.g = 0;
this.parent = null;
}
/**
* Point Constructor
*
* @param row the index of the row in which the point is
* @param col the index of the col in which the point is
* @param g the distance of the point away from the start point
*/
public Point(int row, int col, int g, Point parent)
{
this.row = row;
this.col = col;
this.g = g;
this.parent = parent;
}
/**
* Gets the row of the point
*
* @return the row index of the point
*/
public int getRow()
{
return this.row;
}
/**
* Gets the col of the point
*
* @return the column index of the point
*/
public int getCol()
{
return this.col;
}
/**
* Gets the g of the point
*
* @return the distance from this point to the start point
*/
public int getG()
{
return this.g;
}
/**
* Gets the score of the point
*
* @return the score of the point (G + Manhattan distance to end)
*/
public int getScore()
{
return this.score;
}
/**
* Gets the previous node
*
* @return the parent node of the point
*/
public Point getParent()
{
return this.parent;
}
/**
* Sets the row to a new value
*
* @param newRow new value for our row field
*/
public void setRow(int newRow)
{
this.row = newRow;
}
/**
* Sets the col to new value
*
* @param newCol new value for our col field
*/
public void setCol(int newCol)
{
this.col = newCol;
}
/**
* Sets the g field to a new value
*
* @param newG new value for the g field
*/
public void setG(int newG)
{
this.g = newG;
}
/**
* Sets the score field to a new value
*
* @param newScore new value for the score field
*/
public void setScore(int newScore)
{
this.score = newScore;
}
/**
* Checks if two Points are the same
*
* @param other point to compare to this point
* @return true or false depending on whether they are the same or not
*/
public boolean equals(Point other)
{
return this.row == other.row && this.col == other.col;
}
}