Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs2-19wi
lab09
Commits
dd983741
Commit
dd983741
authored
5 years ago
by
Hale Obernolte
Browse files
Options
Download
Email Patches
Plain Diff
Update Point.java to properly override equals
parent
9cd21dd5
patch-1
1 merge request
!4
Update Point.java to properly override equals
Pipeline
#28866
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/edu/caltech/cs2/lab09/Point.java
+5
-18
src/edu/caltech/cs2/lab09/Point.java
with
5 additions
and
18 deletions
+5
-18
src/edu/caltech/cs2/lab09/Point.java
View file @
dd983741
...
...
@@ -11,29 +11,16 @@ public class Point {
this
.
parent
=
null
;
}
/*
* Returns true if the point passed has the same x and y coordinate as
* this point, or false otherwise.
*/
public
boolean
isEqual
(
Point
point
)
{
if
(
point
==
null
)
return
false
;
int
x
=
point
.
x
;
int
y
=
point
.
y
;
return
(
this
.
x
==
x
&&
this
.
y
==
y
);
}
/*
* Returns true if the point passed has the same x and y coordinate as
* this point, or false otherwise.
*/
@Override
public
boolean
equals
(
Object
point
)
{
if
(!(
point
instanceof
Point
))
{
return
false
;
public
boolean
equals
(
Object
o
)
{
if
(!(
o
instanceof
Point
))
{
return
false
;
}
Point
p
=
(
Point
)
point
;
int
x
=
p
.
x
;
int
y
=
p
.
y
;
return
(
this
.
x
==
x
&&
this
.
y
==
y
);
Point
p
=
(
Point
)
o
;
return
(
this
.
x
==
p
.
x
&&
this
.
y
==
p
.
y
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help