Skip to content
Snippets Groups Projects
Commit 7a9144a2 authored by Oscar-git97's avatar Oscar-git97
Browse files

issues with neighbors

parent 39e5e2bd
No related branches found
No related tags found
No related merge requests found
Showing
with 1799 additions and 1718 deletions
......@@ -2693,3 +2693,47 @@ user global configuration and to define the default location to store repositori
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!SESSION 2024-11-13 18:43:56.685 -----------------------------------------------
eclipse.buildId=4.30.0.20231201-1200
java.version=17.0.9
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
!ENTRY ch.qos.logback.classic 1 0 2024-11-13 18:47:05.605
!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized.
!ENTRY org.eclipse.core.resources 2 10035 2024-11-13 18:47:14.474
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.
!ENTRY ch.qos.logback.classic 1 0 2024-11-13 18:47:17.880
!MESSAGE Logback config file: C:\DevCCI\Eclipse\CCI_Java\.metadata\.plugins\org.eclipse.m2e.logback\logback.2.2.1.20231030-1438.xml
!ENTRY org.eclipse.jface 2 0 2024-11-13 18:47:31.076
!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2024-11-13 18:47:31.076
!MESSAGE A conflict occurred for CTRL+SHIFT+T:
Binding(CTRL+SHIFT+T,
ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type,
Open a type in a Java editor,
Category(org.eclipse.ui.category.navigate,Navigate,null,true),
WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.navigate.open.type"),
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)
Binding(CTRL+SHIFT+T,
ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace,
,
Category(org.eclipse.lsp4e.category,Language Servers,null,true),
WorkbenchHandlerServiceHandler("org.eclipse.lsp4e.symbolinworkspace"),
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)
!ENTRY org.eclipse.egit.ui 2 0 2024-11-13 18:48:04.359
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\oscar'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -32,3 +32,7 @@
1731510605817 Copy package
1731518149529 Rename method 'isValidPosition'
1731518173003 Rename method 'isOutOfBounds'
1731518557953 Copy package
1731518920201 Rename package 'tp6.v2'
1731518936799 Rename package 'tp6.v3'
1731518944880 Rename package 'tp6.v33'
......@@ -22,3 +22,5 @@
2024-11-12 19:33:48,659 [Worker-0: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
2024-11-12 19:55:49,623 [Worker-19: Remove Repositories] WARN org.eclipse.jgit.lib.Repository - close() called when useCnt is already zero for Repository[C:\DevCCI\Git\.git]
2024-11-13 09:37:18,042 [Worker-44: Remove Repositories] WARN org.eclipse.jgit.lib.Repository - close() called when useCnt is already zero for Repository[C:\DevCCI\Git\CCI_Java\.git]
2024-11-13 12:51:23,509 [Worker-1: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read.
2024-11-13 18:48:03,911 [Worker-1: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read.
#Wed Nov 13 12:49:13 CET 2024
#Wed Nov 13 18:47:13 CET 2024
org.eclipse.core.runtime=2
org.eclipse.platform=4.30.0.v20231201-0110
......@@ -10,6 +10,7 @@ public class Cell {
private int row;
private int column;
private boolean active;
private int neighbors;
public Cell(boolean isMine, int row, int column) {
this.isRevealed = false;
......@@ -55,6 +56,14 @@ public class Cell {
this.isMine = isMine;
}
public void setNeighbors(int neighbors) {
this.neighbors = neighbors;
}
public int getNeighbors() {
return neighbors;
}
public boolean getIsSelected() {
return isSelected;
}
......
......@@ -29,23 +29,44 @@ public class Minesweeper {
this.board.get(row).add(cell);
}
}
setNeighbors();
}
public double getDifficulte() {
return difficulte;
private void setNeighbors() {
// TODO Auto-generated method stub
for (ArrayList<Cell> row : board)
for (Cell cell : row) {
cell.setNeighbors(countNeighbors(cell));
}
public void setDifficulte(double difficulte) {
this.difficulte = difficulte;
}
public Color getColorSweeper() {
return colorSweeper;
}
private int countNeighbors(Cell cell) {
int res = 0;
for (int row = cell.getRow() - 1; row <= (cell.getRow() + 1); row++)
for (int col = cell.getColumn() - 1; col <= (cell.getColumn() + 1); col++) {
if (isValidPositionLC(row, col) && !(row == cell.getRow()) && !(col == cell.getRow()))
// if (!(row == cell.getRow()) && !(col == cell.getRow()) && isMine(row, col))
res++;
public void setColorSweeper(Color color) {
this.colorSweeper = color;
}
return res;
}
// public double getDifficulte() {
// return difficulte;
// }
//
// public void setDifficulte(double difficulte) {
// this.difficulte = difficulte;
// }
// public Color getColorSweeper() {
// return colorSweeper;
// }
//
// public void setColorSweeper(Color color) {
// this.colorSweeper = color;
// }
public int getNbColumns() {
return nbColumns;
......@@ -94,9 +115,9 @@ public class Minesweeper {
board.get(line).get(column).setSelected(true);
}
public void deselect(int line, int column) {
board.get(line).get(column).setSelected(false);
}
// public void deselect(int line, int column) {
// board.get(line).get(column).setSelected(false);
// }
public boolean isValidPositionLC(int line, int column) {
boolean lineCheck = line <= nbLines && line > 0;
......
......@@ -97,9 +97,6 @@ public class MinesweeperPanel extends JPanel implements MinesweeperPanelable {
int yTmp = getCellY(tmp.getRow());
g.drawRect(xTmp, yTmp, getCellWidth(), getCellHeight());
if (tmp.isSelected) {
g.setColor(Color.RED);
g.fillRect(xTmp, yTmp, getCellWidth(), getCellHeight());
......@@ -110,14 +107,17 @@ public class MinesweeperPanel extends JPanel implements MinesweeperPanelable {
g.drawRect(xTmp, yTmp, getCellWidth(), getCellHeight());
int sizeBomb = 25;
g.setColor(Color.BLACK);
g.fillOval(xTmp + (getCellWidth() / 2) - (sizeBomb / 2),
yTmp + (getCellHeight() / 2) - (sizeBomb / 2), sizeBomb, sizeBomb);
g.fillOval(xTmp + (getCellWidth() / 2) - (sizeBomb / 2), yTmp + (getCellHeight() / 2) - (sizeBomb / 2),
sizeBomb, sizeBomb);
} else if (tmp.toString().equals("C")) {
g.setColor(Color.DARK_GRAY);
g.fillRect(xTmp, yTmp, getCellWidth(), getCellHeight());
} else {
g.setColor(Color.GRAY);
g.fillRect(xTmp, yTmp, getCellWidth(), getCellHeight());
g.setColor(Color.BLACK);
g.setFont(new Font("Ariel", Font.BOLD, 35));
g.drawString(String.valueOf(tmp.getNeighbors()), xTmp + 15, (yTmp + getCellHeight() - 10));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment