Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed NurikabeCell.java from if/else to switch statements #544

Merged
merged 6 commits into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,30 @@ public NurikabeType getType() {
*/
@Override
public void setType(Element e, MouseEvent m) {
if (e.getElementID().equals("NURI-PLAC-0001")) {
this.data = -1;
}
else {
if (e.getElementID().equals("NURI-PLAC-0002")) {
switch (e.getElementID()){
case "NURI-PLAC-0001":
this.data = -1;
case "NURI-PLAC-0002":
this.data = 0;
}
else {
if (e.getElementID().equals("NURI-UNPL-0001")) {
if (m.getButton() == MouseEvent.BUTTON1) {
case "NURI-UNPL-0001":
switch (m.getButton()){
case MouseEvent.BUTTON1:
if (this.data <= 0 || this.data > 8) {
this.data = 1;
}
else {
this.data = this.data + 1;
}
}
else {
if (m.getButton() == MouseEvent.BUTTON3) {
if (this.data > 1) {
this.data = this.data - 1;
}
else {
this.data = 9;
}
case MouseEvent.BUTTON3:
if (this.data > 1) {
this.data = this.data - 1;
}
else {
this.data = 9;
}
}
}
else { // unknown tile
this.data = -2;
}
}
default:
this.data = -2;
}
}

Expand All @@ -94,4 +86,4 @@ public NurikabeCell copy() {
copy.setGiven(isGiven);
return copy;
}
}
}