From d40bb5a4b4bfb330076f24a36549fed17f30b4cc Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 29 Sep 2023 16:57:40 -0400 Subject: [PATCH] Reformatted code in STT --- .../shorttruthtable/ShortTruthTableBoard.java | 3 +-- .../shorttruthtable/ShortTruthTableCell.java | 24 +++++++------------ .../ShortTruthTableCellFactory.java | 6 ++--- .../ShortTruthTableCellType.java | 1 + .../ShortTruthTableController.java | 6 ++--- .../ShortTruthTableImporter.java | 9 +++---- .../ShortTruthTableStatement.java | 18 +++++--------- 7 files changed, 23 insertions(+), 44 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index e5011182a..a8707c657 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -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()); } } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCell.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCell.java index 59b5f4272..2bc2fe29b 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCell.java @@ -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') { @@ -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 = '>'; } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellFactory.java index 99d626447..182047369 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellFactory.java @@ -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)"); } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellType.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellType.java index c01fe74d8..c997faf5f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellType.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellType.java @@ -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 */ diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableController.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableController.java index bddde44a5..2850282e7 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableController.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableController.java @@ -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(); } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java index 84d04fb45..194941d17 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java @@ -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"); @@ -195,8 +194,7 @@ private ShortTruthTableBoard generateBoard(List> 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); @@ -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"); } } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java index e40a10cf0..38df74b97 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java @@ -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; } @@ -90,8 +88,7 @@ static String removeParens(String statement) { char c = statement.charAt(i); if (c == '(') { openParenCount++; - } - else { + } else { if (c == ')') openParenCount--; } @@ -123,8 +120,7 @@ int parse(String statement) { //keep track of the open parens if (c == '(') { openParenCount++; - } - else { + } else { if (c == ')') { openParenCount--; } @@ -159,8 +155,7 @@ static void removeParens(List cells) { char c = cells.get(i).getSymbol(); if (c == '(') { openParenCount++; - } - else { + } else { if (c == ')') openParenCount--; } @@ -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); } }