Skip to content

Commit

Permalink
Automated Java code formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram28 committed Apr 16, 2024
1 parent 8b486aa commit 30b6e5e
Show file tree
Hide file tree
Showing 54 changed files with 1,203 additions and 1,193 deletions.
16 changes: 9 additions & 7 deletions src/main/java/edu/rpi/legup/model/gameboard/GridRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
import java.util.List;

public abstract class GridRegion<T> {

protected List<T> regionCells;

/**
* Region Constructor
*/

/** Region Constructor */
public GridRegion() {
this.regionCells = new ArrayList<>();
}

/**
* Adds the cell to the region
*
* @param cell cell to be added to the region
*/
public void addCell(T cell) {
Expand All @@ -24,6 +23,7 @@ public void addCell(T cell) {

/**
* Removes the cell from the region
*
* @param cell cell to be remove from the region
*/
public void removeCell(T cell) {
Expand All @@ -32,6 +32,7 @@ public void removeCell(T cell) {

/**
* Returns the list of cells in the region
*
* @return list of cells in region
*/
public List<T> getCells() {
Expand All @@ -40,14 +41,15 @@ public List<T> getCells() {

/**
* Returns the number of cells in the region
*
* @return number of cells in the region
*/
public int getSize(){
public int getSize() {
return regionCells.size();
}

/*
public void colorRegion(){}
*/

}
131 changes: 64 additions & 67 deletions src/main/java/edu/rpi/legup/puzzle/minesweeper/Minesweeper.java
Original file line number Diff line number Diff line change
@@ -1,67 +1,64 @@
package edu.rpi.legup.puzzle.minesweeper;

import edu.rpi.legup.model.Puzzle;
import edu.rpi.legup.model.gameboard.Board;
import edu.rpi.legup.model.gameboard.PuzzleElement;
import edu.rpi.legup.model.rules.ContradictionRule;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class Minesweeper extends Puzzle {

public static final String NAME = "Minesweeper";

public Minesweeper() {
this.name = NAME;
this.importer = new MinesweeperImporter(this);
this.exporter = new MinesweeperExporter(this);
this.factory = MinesweeperCellFactory.INSTANCE;
}

@Override
@Contract(pure = false)
public void initializeView() {
this.boardView = new MinesweeperView((MinesweeperBoard) this.currentBoard);
this.boardView.setBoard(this.currentBoard);
addBoardListener(boardView);
}

@Override
@Contract("_ -> null")
public @Nullable Board generatePuzzle(int difficulty) {
return null;
}

@Override
@Contract(pure = true)
public boolean isBoardComplete(@NotNull Board board) {
MinesweeperBoard minesweeperBoard = (MinesweeperBoard) board;

for (ContradictionRule rule : contradictionRules) {
if (rule.checkContradiction(minesweeperBoard) == null) {
return false;
}
}
for (PuzzleElement<?> data : minesweeperBoard.getPuzzleElements()) {
final MinesweeperCell cell = (MinesweeperCell) data;
if (cell.getData().equals(MinesweeperTileData.empty())) {
return false;
}
}
return true;
}

@Override
@Contract(pure = true)
public void onBoardChange(@NotNull Board board) {

}

@Override
@Contract(pure = true)
public boolean isValidDimensions(int rows, int columns) {
return rows >= 1 && columns >= 1;
}

}
package edu.rpi.legup.puzzle.minesweeper;

import edu.rpi.legup.model.Puzzle;
import edu.rpi.legup.model.gameboard.Board;
import edu.rpi.legup.model.gameboard.PuzzleElement;
import edu.rpi.legup.model.rules.ContradictionRule;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class Minesweeper extends Puzzle {

public static final String NAME = "Minesweeper";

public Minesweeper() {
this.name = NAME;
this.importer = new MinesweeperImporter(this);
this.exporter = new MinesweeperExporter(this);
this.factory = MinesweeperCellFactory.INSTANCE;
}

@Override
@Contract(pure = false)
public void initializeView() {
this.boardView = new MinesweeperView((MinesweeperBoard) this.currentBoard);
this.boardView.setBoard(this.currentBoard);
addBoardListener(boardView);
}

@Override
@Contract("_ -> null")
public @Nullable Board generatePuzzle(int difficulty) {
return null;
}

@Override
@Contract(pure = true)
public boolean isBoardComplete(@NotNull Board board) {
MinesweeperBoard minesweeperBoard = (MinesweeperBoard) board;

for (ContradictionRule rule : contradictionRules) {
if (rule.checkContradiction(minesweeperBoard) == null) {
return false;
}
}
for (PuzzleElement<?> data : minesweeperBoard.getPuzzleElements()) {
final MinesweeperCell cell = (MinesweeperCell) data;
if (cell.getData().equals(MinesweeperTileData.empty())) {
return false;
}
}
return true;
}

@Override
@Contract(pure = true)
public void onBoardChange(@NotNull Board board) {}

@Override
@Contract(pure = true)
public boolean isValidDimensions(int rows, int columns) {
return rows >= 1 && columns >= 1;
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
package edu.rpi.legup.puzzle.minesweeper;

import edu.rpi.legup.model.gameboard.GridBoard;

public class MinesweeperBoard extends GridBoard {

public MinesweeperBoard(int width, int height) {
super(width, height);
}

public MinesweeperBoard(int size) {
super(size);
}

@Override
public MinesweeperCell getCell(int x, int y) {
return (MinesweeperCell) super.getCell(x, y);
}


/**
* Performs a deep copy of the Board
*
* @return a new copy of the board that is independent of this one
*/
@Override
public MinesweeperBoard copy() {
MinesweeperBoard newMinesweeperBoard = new MinesweeperBoard(this.dimension.width, this.dimension.height);
for (int x = 0; x < this.dimension.width; x++) {
for (int y = 0; y < this.dimension.height; y++) {
newMinesweeperBoard.setCell(x, y, getCell(x, y).copy());
}
}
return newMinesweeperBoard;
}
}
package edu.rpi.legup.puzzle.minesweeper;

import edu.rpi.legup.model.gameboard.GridBoard;

public class MinesweeperBoard extends GridBoard {

public MinesweeperBoard(int width, int height) {
super(width, height);
}

public MinesweeperBoard(int size) {
super(size);
}

@Override
public MinesweeperCell getCell(int x, int y) {
return (MinesweeperCell) super.getCell(x, y);
}

/**
* Performs a deep copy of the Board
*
* @return a new copy of the board that is independent of this one
*/
@Override
public MinesweeperBoard copy() {
MinesweeperBoard newMinesweeperBoard =
new MinesweeperBoard(this.dimension.width, this.dimension.height);
for (int x = 0; x < this.dimension.width; x++) {
for (int y = 0; y < this.dimension.height; y++) {
newMinesweeperBoard.setCell(x, y, getCell(x, y).copy());
}
}
return newMinesweeperBoard;
}
}
Loading

0 comments on commit 30b6e5e

Please sign in to comment.