Skip to content

Commit

Permalink
Reformatted code in STT
Browse files Browse the repository at this point in the history
  • Loading branch information
charlestian23 committed Sep 29, 2023
1 parent a52b931 commit d40bb5a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ 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,8 +168,7 @@ 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 @@ -184,37 +183,30 @@ 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,11 +41,9 @@ 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 @@ -26,6 +26,7 @@ public static ShortTruthTableCellType valueOf(int cellType) {

/**
* Gets the char value of a cell, Used for debugging
*
* @param type cell type input
* @return true if value is 1, false if value is 0, ? if value is -1, or blank otherwise
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ 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 @@ -155,8 +155,7 @@ 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 @@ -195,8 +194,7 @@ 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 @@ -308,8 +306,7 @@ 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,15 +61,13 @@ 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 @@ -90,8 +88,7 @@ static String removeParens(String statement) {
char c = statement.charAt(i);
if (c == '(') {
openParenCount++;
}
else {
} else {
if (c == ')') openParenCount--;
}

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

Expand Down Expand Up @@ -300,8 +295,7 @@ 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 d40bb5a

Please sign in to comment.