Skip to content

Commit

Permalink
Reformatted code again
Browse files Browse the repository at this point in the history
  • Loading branch information
charlestian23 committed Sep 29, 2023
1 parent 2016f0a commit 53358b5
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ public boolean isValidDimensions(int rows, int columns) {
* @return true if the statements are valid for Short Truth Table, false otherwise
*/
public boolean isValidTextInput(String[] statements) {
if (statements.length == 0)
if (statements.length == 0) {
return false;
}

ShortTruthTableImporter importer = (ShortTruthTableImporter) this.getImporter();
for (String s : statements)
if (!importer.validGrammar(s))
for (String s : statements) {
if (!importer.validGrammar(s)) {
return false;
}
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public ShortTruthTableBoard copy() {
for (int c = 0; c < this.dimension.width; c++) {
if (r % 2 == 0 && c < statementsCopy[r / 2].getLength()) {
boardCopy.setCell(c, r, statementsCopy[r / 2].getCell(c));
} else {
}
else {
boardCopy.setCell(c, r, getCell(c, r).copy());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public void setType(Element e, MouseEvent m) {
if (this.symbol > 'Z') {
this.symbol = 'A';
}
} else {
}
else {
if (m.getButton() == MouseEvent.BUTTON3) {
this.symbol -= 1;
if (this.symbol < 'A') {
Expand All @@ -183,30 +184,37 @@ public void setType(Element e, MouseEvent m) {
if (m.getButton() == MouseEvent.BUTTON1) {
if (this.symbol == '^') {
this.symbol = '|';
} else {
}
else {
if (this.symbol == '|') {
this.symbol = '>';
} else {
}
else {
if (this.symbol == '>') {
this.symbol = '-';
} else {
}
else {
if (this.symbol == '-') {
this.symbol = '^';
}
}
}
}
} else {
}
else {
if (m.getButton() == MouseEvent.BUTTON3) {
if (this.symbol == '^') {
this.symbol = '-';
} else {
}
else {
if (this.symbol == '|') {
this.symbol = '^';
} else {
}
else {
if (this.symbol == '>') {
this.symbol = '|';
} else {
}
else {
if (this.symbol == '-') {
this.symbol = '>';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ public ShortTruthTableCell importCell(Node node, Board board) throws InvalidFile

return cell;

} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
throw new InvalidFileFormatException("nurikabe Factory: unknown value where integer expected");
} catch (NullPointerException e) {
}
catch (NullPointerException e) {
throw new InvalidFileFormatException("nurikabe Factory: could not find attribute(s)");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ public void changeCell(MouseEvent e, PuzzleElement data) {
if (e.getButton() == MouseEvent.BUTTON1) {
if (e.isControlDown()) {
this.boardView.getSelectionPopupMenu().show(boardView, this.boardView.getCanvas().getX() + e.getX(), this.boardView.getCanvas().getY() + e.getY());
} else {
}
else {
cell.cycleTypeForward();
}
} else {
}
else {
if (e.getButton() == MouseEvent.BUTTON3) {
cell.cycleTypeBackward();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ public ShortTruthTableExporter(ShortTruthTable stt) {
@Override
protected org.w3c.dom.Element createBoardElement(Document newDocument) {
ShortTruthTableBoard board;
if (puzzle.getTree() != null)
if (puzzle.getTree() != null) {
board = (ShortTruthTableBoard) puzzle.getTree().getRootNode().getBoard();
else
}
else {
board = (ShortTruthTableBoard) puzzle.getBoardView().getBoard();
}

org.w3c.dom.Element boardElement = newDocument.createElement("board");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ protected boolean validGrammar(String sentence) {
}
}
}
} else {
}
else {
if (i != sentence.length() - 1) {
if (Character.isLetter(sentence.charAt(i + 1))) {
System.out.println("Invalid next character");
Expand Down Expand Up @@ -194,7 +195,8 @@ private ShortTruthTableBoard generateBoard(List<List<ShortTruthTableCell>> allCe
if (y % 2 == 0 && x < statements.get(statementIndex).getLength()) {
cell = allCells.get(statementIndex).get(x);
System.out.println("Importer: check cell statement ref: " + cell.getStatementReference());
} else {
}
else {
//if it is not a valid cell space, add a NOT_IN_PLAY cell
cell = new ShortTruthTableCell(' ', ShortTruthTableCellType.NOT_IN_PLAY, new Point(x, y));
cell.setModifiable(false);
Expand Down Expand Up @@ -306,7 +308,8 @@ public void initializeBoard(Node node) throws InvalidFileFormatException {

puzzle.setCurrentBoard(sttBoard);

} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
throw new InvalidFileFormatException("short truth table Importer: unknown value where integer expected");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ private ShortTruthTableStatement(String statement, ShortTruthTableStatement pare
//construct sub-statements if necessary
if (left.length() > 0) {
leftStatement = new ShortTruthTableStatement(left, this, leftCells);
} else {
}
else {
leftStatement = null;
}

if (right.length() > 0) {
rightStatement = new ShortTruthTableStatement(right, this, rightCells);
} else {
}
else {
rightStatement = null;
}

Expand All @@ -88,7 +90,8 @@ static String removeParens(String statement) {
char c = statement.charAt(i);
if (c == '(') {
openParenCount++;
} else {
}
else {
if (c == ')') openParenCount--;
}

Expand Down Expand Up @@ -120,7 +123,8 @@ int parse(String statement) {
//keep track of the open parens
if (c == '(') {
openParenCount++;
} else {
}
else {
if (c == ')') {
openParenCount--;
}
Expand Down Expand Up @@ -155,7 +159,8 @@ static void removeParens(List<ShortTruthTableCell> cells) {
char c = cells.get(i).getSymbol();
if (c == '(') {
openParenCount++;
} else {
}
else {
if (c == ')') openParenCount--;
}

Expand Down Expand Up @@ -295,7 +300,8 @@ public ShortTruthTableStatement replace(int column, ShortTruthTableCell cell) {
for (ShortTruthTableCell c : cells) {
if (c.getX() == column) {
cellsCopy.add(cell);
} else {
}
else {
cellsCopy.add(c);
}
}
Expand Down

0 comments on commit 53358b5

Please sign in to comment.