From da627552b51a963c7d6e31e86079d92577398292 Mon Sep 17 00:00:00 2001 From: cleme Date: Thu, 10 Apr 2025 09:54:16 +0200 Subject: [PATCH] Constructor Piece --- OOP_1A2_Project/src/backend/Piece.java | 49 ++++++++++++++++++-------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/OOP_1A2_Project/src/backend/Piece.java b/OOP_1A2_Project/src/backend/Piece.java index ffa88bb..9abdb69 100644 --- a/OOP_1A2_Project/src/backend/Piece.java +++ b/OOP_1A2_Project/src/backend/Piece.java @@ -1,21 +1,40 @@ package backend; public class Piece { + private int x; + private int y; + private ChessPieceType type; + private boolean isWhite; - public int getX() { - return 0; - } + public Piece(int x, int y, ChessPieceType type, boolean isWhite) { + this.x = x; + this.y = y; + this.type = type; + this.isWhite = isWhite; // true if the piece is white, false if black + } - public int getY() { - return 0; - } - - public PieceType getType() { - return null; - } - - public boolean isWhite() { - return false; - } - + public int getX() { + return x; + } + + public int getY() { + return y; + } + + public ChessPieceType getType() { + return type; + } + + public boolean isWhite() { + return isWhite; // Returns true if the piece is white, false if black + } +} + +enum ChessPieceType { + Pawn, + Rook, + Knight, + Bishop, + Queen, + King }