Skip to content

Commit 4725f8d

Browse files
committed
fix nullpointerexception
1 parent fa590a8 commit 4725f8d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

14/src/Node.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ void insertAllChildren(Node node) {
5757
* @return true if shape has been deleted
5858
*/
5959
boolean delete(Shape s) {
60-
if (left.shape == s) {
60+
if (left != null && left.shape == s) {
6161
Node rightNode = left.right;
6262
left = left.left;
6363
left.insertAllChildren(rightNode);
6464
return true;
65-
} else if (right.shape == s) {
65+
} else if (right != null && right.shape == s) {
6666
Node rightNode = right.right;
6767
right = right.left;
6868
right.insertAllChildren(rightNode);
6969
return true;
7070
} else {
71-
return left.delete(s) || right.delete(s);
71+
return (left != null && left.delete(s)) || (right != null && right.delete(s));
7272
}
7373
}
7474
}

0 commit comments

Comments
 (0)