From 70739853c7d15e89637af6a19b2a2d4eb60c9523 Mon Sep 17 00:00:00 2001 From: Jose Srifi Date: Thu, 9 May 2019 10:26:09 +0200 Subject: [PATCH 1/3] update Piece.java Class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - passage de la classe en Abstract - ajout booléen de verif de déplacement - ajout méthode aBouge() universelle à toutes les pièces - ajout méthode abstract deplacable --- src/piecesEchiquier/Piece.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/piecesEchiquier/Piece.java b/src/piecesEchiquier/Piece.java index 5c214a0..4445962 100755 --- a/src/piecesEchiquier/Piece.java +++ b/src/piecesEchiquier/Piece.java @@ -1,6 +1,6 @@ package piecesEchiquier; -public class Piece { +public abstract class Piece { private String couleur; @@ -8,7 +8,7 @@ public class Piece { private boolean enVie = true; private Position position; private Position ini; - + private boolean verif = false; //constructeur par defaut qui devrait probablement remplacer vide @@ -34,6 +34,23 @@ public class Piece { } + public boolean aBouge() + { + + if(this.getIni() != this.getPosition()) + { + verif=true; + } + if(this.getIni() == this.getPosition() && verif == false) + { + verif=false; + } + return verif; + } + + public abstract boolean[][] deplacable(Echiquier e,Piece p); + + /* //verifie une eventuelle collision a chaque case public boolean collision(Case caseArrivee){ return caseArrivee.estVide(); From 8f6df580b0662d63afc4f0f5b738015c51872aa8 Mon Sep 17 00:00:00 2001 From: Jose Srifi Date: Thu, 9 May 2019 10:27:45 +0200 Subject: [PATCH 2/3] update Tour.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit suppression méthode aBouge() car présente dansclasse parente. --- src/piecesEchiquier/Tour.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/piecesEchiquier/Tour.java b/src/piecesEchiquier/Tour.java index 5b49f6c..2c76222 100755 --- a/src/piecesEchiquier/Tour.java +++ b/src/piecesEchiquier/Tour.java @@ -1,26 +1,12 @@ package piecesEchiquier; public class Tour extends Piece { - private boolean verif=false; public Tour(String couleur,String l, Position pos) { super(couleur,l,pos); } - public boolean aBouge() - { - if(this.getIni() != this.getPosition()) - { - verif=true; - } - if(this.getIni() == this.getPosition() && verif == false) - { - verif=false; - } - return verif; - } - public boolean[][] deplacable(Echiquier e,Piece p) { boolean[][] deplacementsInherentsPiece = new boolean[8][8]; Position position = this.getPosition(); From 57715821447527d77b5079f4c40a44c977cedbd2 Mon Sep 17 00:00:00 2001 From: Jose Srifi Date: Thu, 9 May 2019 10:40:17 +0200 Subject: [PATCH 3/3] update class Fou.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ajout méthode a bouge --- src/piecesEchiquier/Fou.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/piecesEchiquier/Fou.java b/src/piecesEchiquier/Fou.java index a6378f0..01aa863 100755 --- a/src/piecesEchiquier/Fou.java +++ b/src/piecesEchiquier/Fou.java @@ -2,10 +2,25 @@ package piecesEchiquier; public class Fou extends Piece { - public Fou(String c,String l, Position pos) - { - super(c,l,pos); + public Fou(String c,String n, Position pos) + {//c = couleur, n = nom, pos = position + super(c,n,pos); } + public boolean[][] deplacable(Echiquier e,Piece p) { + boolean[][] deplacementsInherentsPiece = new boolean[8][8]; + Position position = this.getPosition(); + int x = position.getX(); + int y = position.getY(); + + for(int i=x; i<8; i++) { + deplacementsInherentsPiece[i][y]=true; + } + for(int j=0; j<8; j++) { + deplacementsInherentsPiece[x][j]=true; + } + deplacementsInherentsPiece[x][y]=false; + return deplacementsInherentsPiece; + } }