Skip to content

Commit

Permalink
Merge branch 'puzzle_editor-short_truth_table' into puzzle_editor-sho…
Browse files Browse the repository at this point in the history
…rt_truth_table
  • Loading branch information
charlestian23 authored Sep 26, 2023
2 parents 2daca5c + f994a07 commit 0cb069b
Show file tree
Hide file tree
Showing 58 changed files with 429 additions and 196 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish-javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
push:
branches:
- dev
permissions:
contents: write

jobs:
publish:
Expand Down
2 changes: 1 addition & 1 deletion bin/main/edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spreadsheet : https://docs.google.com/spreadsheets/d/1l7aUZtavtysM8dtGnaEIXhBKMR
4. Refactoring:
- document utility functions in the reference sheet, COMMENTS!
- review and identify dead code
- remove all these damn print statments (commented ones too if they aren't useful)
- remove all these damn print statements (commented ones too if they aren't useful)
- Edit to allow blank clues
- Display flags somewhere
5. Flags
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/rpi/legup/app/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Config {
/**
* Config Constructor for logic puzzles
*
* @throws InvalidConfigException
* @throws InvalidConfigException if configuration is invalid
*/
public Config() throws InvalidConfigException {
this.puzzles = new Hashtable<>();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/edu/rpi/legup/app/GameBoardFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ public void loadPuzzle(String game, String[] statements) {
* Loads a puzzle file
*
* @param fileName file name of the board file
* @throws InvalidFileFormatException if input is invalid
*/
public void loadPuzzle(String fileName) throws InvalidFileFormatException {
try {
Expand Down Expand Up @@ -344,7 +345,7 @@ public void loadPuzzleEditor(InputStream inputStream) throws InvalidFileFormatEx

/**
* Loads a puzzle file from the input stream
*
* @throws InvalidFileFormatException if input is invalid
* @param inputStream input stream for the puzzle file
*/
public void loadPuzzle(InputStream inputStream) throws InvalidFileFormatException {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/edu/rpi/legup/app/LegupPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class LegupPreferences {

private static LegupPreferences instance;

private static String SAVED_PATH = "";

private static final Preferences preferences = Preferences.userNodeForPackage(LegupPreferences.class);

private static final Map<String, String> preferencesMap = new HashMap<>();
Expand Down Expand Up @@ -104,4 +106,13 @@ public boolean getUserPrefAsBool(String key) {
}
}
}


public String getSavedPath() {
return SAVED_PATH;
}

public void setSavedPath(String path) {
SAVED_PATH = path;
}
}
3 changes: 3 additions & 0 deletions src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class AutoCaseRuleCommand extends PuzzleCommand {
*
* @param elementView currently selected puzzle puzzleElement view that is being edited
* @param selection currently selected tree puzzleElement views that is being edited
* @param caseRule currently selected caseRule puzzleElement view that is being edited
* @param caseBoard currently selected caseBoard puzzleElement view that is being edited
* @param mouseEvent currently selected mouseEvent puzzleElement view that is being edited
*/
public AutoCaseRuleCommand(ElementView elementView, TreeViewSelection selection, CaseRule caseRule, CaseBoard caseBoard, MouseEvent mouseEvent) {
this.elementView = elementView;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/edu/rpi/legup/history/ICommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

public interface ICommand {
/**
* Executes an command
* Executes a command
*/
void execute();

/**
* Determines whether this command can be executed
* @return true if can execute, false otherwise
*/
boolean canExecute();

Expand All @@ -20,12 +21,12 @@ public interface ICommand {
String getError();

/**
* Undoes an command
* Undoes a command
*/
void undo();

/**
* Redoes an command
* Redoes a command
*/
void redo();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ValidateCaseRuleCommand extends PuzzleCommand {
* AutoCaseRuleCommand Constructor creates a command for verifying a case rule
*
* @param selection currently selected tree puzzleElement views that is being edited
* @param caseRule currently selected caseRule puzzleElement view that is being edited
*/
public ValidateCaseRuleCommand(TreeViewSelection selection, CaseRule caseRule) {
this.selection = selection.copy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ValidateContradictionRuleCommand extends PuzzleCommand {
* ValidateContradictionRuleCommand Constructor creates a puzzle command for verifying a contradiction rule
*
* @param selection currently selected tree puzzleElement views
* @param rule contradiction rule to set to all of the tree elements
* @param rule contradiction rule to be set to all the tree elements
*/
public ValidateContradictionRuleCommand(TreeViewSelection selection, ContradictionRule rule) {
this.selection = selection.copy();
Expand All @@ -32,7 +32,7 @@ public ValidateContradictionRuleCommand(TreeViewSelection selection, Contradicti
}

/**
* Executes an command
* Executes a command
*/
@Override
public void executeCommand() {
Expand Down Expand Up @@ -117,7 +117,7 @@ public String getErrorString() {
}

/**
* Undoes an command
* Undoes a command
*/
@Override
public void undoCommand() {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/edu/rpi/legup/model/Puzzle.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ public boolean isPuzzleComplete() {
/**
* Imports the board using the file stream
*
* @param fileName
* @throws InvalidFileFormatException
* @param fileName the file that is imported
* @throws InvalidFileFormatException if file is invalid
*/
public void importPuzzle(String fileName) throws InvalidFileFormatException {
try {
Expand All @@ -274,8 +274,8 @@ public void importPuzzle(String fileName) throws InvalidFileFormatException {
/**
* Imports the board using the file stream
*
* @param inputStream
* @throws InvalidFileFormatException
* @param inputStream the file stream that is imported
* @throws InvalidFileFormatException if file stream is invalid
*/
public void importPuzzle(InputStream inputStream) throws InvalidFileFormatException {
Document document;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/edu/rpi/legup/model/PuzzleExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public abstract class PuzzleExporter {

/**
* PuzzleExporter Constructor exports the puzzle object to a file
* @param puzzle puzzle that is to be exported
*/
public PuzzleExporter(Puzzle puzzle) {
this.puzzle = puzzle;
Expand All @@ -35,7 +36,7 @@ public PuzzleExporter(Puzzle puzzle) {
* Exports the puzzle to an xml formatted file
*
* @param fileName name of file to be exported
* @throws ExportFileException
* @throws ExportFileException if puzzle can not be exported
*/
public void exportPuzzle(String fileName) throws ExportFileException {
try {
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/edu/rpi/legup/model/PuzzleImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public abstract class PuzzleImporter {

/**
* PuzzleImporter Constructor creates the puzzle object
* @param puzzle puzzle that is imported
*/
public PuzzleImporter(Puzzle puzzle) {
this.puzzle = puzzle;
Expand All @@ -35,7 +36,7 @@ public PuzzleImporter(Puzzle puzzle) {
*
* @param rows number of rows on the puzzle
* @param columns number of columns on the puzzle
* @throws RuntimeException
* @throws RuntimeException if puzzle can not be made
*/
public void initializePuzzle(int rows, int columns) throws RuntimeException {
if (this.puzzle.isValidDimensions(rows, columns)) {
Expand All @@ -57,7 +58,7 @@ public void initializePuzzle(String[] statements) throws InputMismatchException,
* Initializes the puzzle attributes
*
* @param node xml document node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
public void initializePuzzle(Node node) throws InvalidFileFormatException {
if (node.getNodeName().equalsIgnoreCase("puzzle")) {
Expand Down Expand Up @@ -111,15 +112,15 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException {
*
* @param rows number of rows on the puzzle
* @param columns number of columns on the puzzle
* @throws RuntimeException
* @throws RuntimeException if board can not be created
*/
public abstract void initializeBoard(int rows, int columns);

/**
* Creates an empty board for building
*
* @param node xml document node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
public abstract void initializeBoard(Node node) throws InvalidFileFormatException;

Expand All @@ -129,7 +130,7 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException {
* Creates the proof for building
*
* @param node xml document node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
public void initializeProof(Node node) throws InvalidFileFormatException {
if (node.getNodeName().equalsIgnoreCase("proof")) {
Expand Down Expand Up @@ -163,6 +164,7 @@ public void initializeProof(Node node) throws InvalidFileFormatException {
* Sets the puzzleElement from the xml document node
*
* @param node xml document node
* @throws InvalidFileFormatException if file is invalid
*/
protected void setCells(Node node) throws InvalidFileFormatException {
NodeList dataList = ((org.w3c.dom.Element) node).getElementsByTagName("cell");
Expand All @@ -176,8 +178,8 @@ protected void setCells(Node node) throws InvalidFileFormatException {
/**
* Creates the tree for the edu.rpi.legup.puzzle
*
* @param node
* @throws InvalidFileFormatException
* @param node xml document node
* @throws InvalidFileFormatException if file is invalid
*/
protected void createTree(Node node) throws InvalidFileFormatException {
Element treeElement = (org.w3c.dom.Element) node;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/rpi/legup/model/tree/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Set<TreeElement> getLeafTreeElements() {

/**
* Gets a Set of TreeNodes that are leaf nodes from the sub tree rooted at the specified node
*
* @param node node that is input
* @return Set of TreeNodes that are leaf nodes from the sub tree
*/
public Set<TreeElement> getLeafTreeElements(TreeNode node) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/edu/rpi/legup/model/tree/TreeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,9 @@ public boolean isRoot() {
public void setRoot(boolean isRoot) {
this.isRoot = isRoot;
}

public void clearChildren() {
this.children.clear();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BattleshipCellFactory extends ElementFactory {
* @param node node that represents the puzzleElement
* @param board board to add the newly created cell
* @return newly created cell from the xml document Node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
@Override
public PuzzleElement<BattleshipType> importCell(Node node, Board board) throws InvalidFileFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public boolean acceptsTextInput() {
*
* @param rows the number of rows on the board
* @param columns the number of columns on the board
* @throws RuntimeException
* @throws RuntimeException if board can not be created
*/
@Override
public void initializeBoard(int rows, int columns) {
Expand All @@ -39,7 +39,7 @@ public void initializeBoard(int rows, int columns) {
* Creates the board for building
*
* @param node xml document node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
@Override
public void initializeBoard(Node node) throws InvalidFileFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum BattleshipType {

/**
* Gets the enum of this BattleShipType
*
* @param value the integer value input
* @return enum equivalent BattleShipType of integer value
*/
public static BattleshipType getType(int value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class FillapixCellFactory extends ElementFactory {
* @param node node that represents the puzzleElement
* @param board board to add the newly created cell
* @return newly created cell from the xml document Node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
@Override
public FillapixCell importCell(Node node, Board board) throws InvalidFileFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public boolean acceptsTextInput() {
*
* @param rows the number of rows on the board
* @param columns the number of columns on the board
* @throws RuntimeException
* @throws RuntimeException if board can not be made
*/
@Override
public void initializeBoard(int rows, int columns) {
Expand All @@ -39,7 +39,7 @@ public void initializeBoard(int rows, int columns) {
* Creates the board for building
*
* @param node xml document node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
@Override
public void initializeBoard(Node node) throws InvalidFileFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class HeyawakeFactory extends ElementFactory {
* @param node node that represents the puzzleElement
* @param board board to add the newly created cell
* @return newly created cell from the xml document Node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
@Override
public HeyawakeCell importCell(Node node, Board board) throws InvalidFileFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public boolean acceptsTextInput() {
*
* @param rows the number of rows on the board
* @param columns the number of columns on the board
* @throws RuntimeException
* @throws RuntimeException if board can not be created
*/
@Override
public void initializeBoard(int rows, int columns) {
Expand All @@ -40,7 +40,7 @@ public void initializeBoard(int rows, int columns) {
* Creates the board for building
*
* @param node xml document node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
@Override
public void initializeBoard(Node node) throws InvalidFileFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class LightUpCellFactory extends ElementFactory {
* @param node node that represents the puzzleElement
* @param board board to add the newly created cell
* @return newly created cell from the xml document Node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
@Override
public LightUpCell importCell(Node node, Board board) throws InvalidFileFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public boolean acceptsTextInput() {
*
* @param rows the number of rows on the board
* @param columns the number of columns on the board
* @throws RuntimeException
* @throws RuntimeException if board can not be created
*/
@Override
public void initializeBoard(int rows, int columns) {
Expand All @@ -51,7 +51,7 @@ public void initializeBoard(int rows, int columns) {
* Creates the board for building
*
* @param node xml document node
* @throws InvalidFileFormatException
* @throws InvalidFileFormatException if file is invalid
*/
@Override
public void initializeBoard(Node node) throws InvalidFileFormatException {
Expand Down
Loading

0 comments on commit 0cb069b

Please sign in to comment.