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