56 lines
1.1 KiB
Java
56 lines
1.1 KiB
Java
package ruscz.game.gameOfProd.Cells;
|
|
|
|
import java.awt.*;
|
|
|
|
/**
|
|
* General class for Cell
|
|
*/
|
|
public class Cell {
|
|
private int x, y;
|
|
private final int size;
|
|
private Color color;
|
|
|
|
public Cell(int x, int y, int size, Color color) {
|
|
set(x, y);
|
|
this.size = size;
|
|
this.color = color;
|
|
}
|
|
|
|
/**
|
|
* Set position of Cell
|
|
* @param x X position
|
|
* @param y Y position
|
|
*/
|
|
public void set(int x, int y) {
|
|
this.x = x;
|
|
this.y = y;
|
|
}
|
|
|
|
public void setColor(Color color) {
|
|
this.color = color;
|
|
}
|
|
|
|
public int getX() { // get the X coordinate
|
|
return x;
|
|
}
|
|
|
|
public int getY() { // get the Y coordinate
|
|
return y;
|
|
}
|
|
|
|
public int getSize() { return size; }
|
|
|
|
public void paint(Graphics2D g) {
|
|
g.setColor(color);
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
Cell cell = (Cell) o;
|
|
return x == cell.x &&
|
|
y == cell.y;
|
|
}
|
|
}
|