What is returning false?

With this code, when I run the test method and case two runs, no matter what keys[i] and hide[i] are, it returns false. What is going wrong?(Not sure if it happens with the other cases, my current code sets list to only 0s and 2s)
class Tester {
String[] keys;
boolean[] hide;
int[] list;
Map map;
Room room;
public Tester(Path path, String[] keys, boolean[] hide, int[] list) {
this.keys = keys;
this.room = path.start;
this.map = this.room.map;
this.hide = hide;
this.list = list;
}

boolean test() {
for (int i = 0; i < keys.length; i++) {
switch (list[i]) {
case 1:
if (room.keys.contains(keys[i]) && hide[i]) {
return false;
} else if (!room.keys.contains(keys[i]) && !hide[i]) {
return false;
}
case 2:
if (!map.globals.contains(keys[i]) && hide[i]) {
return false;
} else if (map.globals.contains(keys[i]) && !hide[i]) {
return false;
}
case 3:
if (!room.keys.contains(keys[i])) {
if (map.player.inventory.contains(keys[i])) {

} else {
return false;
}
}
}
}
return true;
}
}
class Tester {
String[] keys;
boolean[] hide;
int[] list;
Map map;
Room room;
public Tester(Path path, String[] keys, boolean[] hide, int[] list) {
this.keys = keys;
this.room = path.start;
this.map = this.room.map;
this.hide = hide;
this.list = list;
}

boolean test() {
for (int i = 0; i < keys.length; i++) {
switch (list[i]) {
case 1:
if (room.keys.contains(keys[i]) && hide[i]) {
return false;
} else if (!room.keys.contains(keys[i]) && !hide[i]) {
return false;
}
case 2:
if (!map.globals.contains(keys[i]) && hide[i]) {
return false;
} else if (map.globals.contains(keys[i]) && !hide[i]) {
return false;
}
case 3:
if (!room.keys.contains(keys[i])) {
if (map.player.inventory.contains(keys[i])) {

} else {
return false;
}
}
}
}
return true;
}
}
5 Replies
JavaBot
JavaBot2y ago
This post has been reserved for your question.
Hey @blockgoblin31! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
blockgoblin31
blockgoblin31OP2y ago
oh... yea, I'm just dumb
JavaBot
JavaBot2y ago
Post Closed
This post has been closed by <@501514065068294154>.
Want results from more Discord servers?
Add your server