From 1431bc0e257a04611a781834c7138246a16ebb2f Mon Sep 17 00:00:00 2001 From: yoyom Date: Tue, 7 May 2024 15:55:56 +0200 Subject: [PATCH] setCell method --- src/backend/Simulator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index abcf719..457f09d 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -157,7 +157,8 @@ public class Simulator extends Thread { return grid[x][y]; } else { - return -1;// If the coordinates are out of the grid, we return -1 as a message error + System.out.println("Error: Coordinates out of the grid."); + return -1;// If the coordinates are out of the grid, we return -1 as an error value } } /** @@ -192,7 +193,12 @@ public class Simulator extends Thread { * @param val to set in cell */ public void setCell(int x, int y, int val) { - //TODO : complete method + if (x >= 0 && x < COL_NUM && y >= 0 && y < LINE_NUM) { + grid[x][y] = val; + } + else { + System.out.println("Error: Coordinates out of the grid."); + } } /**