need help explining please.
hello there i have an exercise given where i will need to re construct my code using binary search tree.
the problem with me is if someone explains the code to me it makes it easier for me to implement.
i have been given a source code to do so, but there is a little section of the code which i get quite confused with. all i need is explaning, if you don't want to write a whole description, could you comment out each line
thank you for your time and help.
Code:
for (int y = 1; y < 8; y++) {
for (int x = 1; x < 8; x++) {
if (btns[x][y].getText().equalsIgnoreCase("R")) {
if ((btns[x + 1][y + 1].getText()
.equalsIgnoreCase("C"))
|| (btns[x][y + 1].getText()
.equalsIgnoreCase("C"))
|| (btns[x + 1][y].getText()
.equalsIgnoreCase("C"))
|| (btns[x - 1][y - 1].getText()
.equalsIgnoreCase("C"))) {
btns[x + 1][y + 1].setIcon(empty);
r = new Random();
int location1 = r.nextInt(4);
if (location == 0) {
x = -2;
y = -2;
btns[x][y].setIcon(cat);
}
if (location == 1) {
x = +2;
y = -2;
btns[x][y].setIcon(cat);
}
if (location == 2) {
x = -2;
y = +2
btns[x][y].setIcon(cat);
}
if (location == 3) {
x = +2;
y = +2;
btns[x][y].setIcon(cat);
}
break;