39 lines
813 B
Java
39 lines
813 B
Java
|
import java.util.*;
|
||
|
|
||
|
public class DonjonNPlocal extends Donjon{
|
||
|
|
||
|
private int indexPiecePerso;
|
||
|
private ArrayList<PieceNPlocal> donjon;
|
||
|
|
||
|
public DonjonNPlocal (ArrayList<PieceNPlocal> pieceDonjon, int positionDepart){
|
||
|
this.donjon = (ArrayList<PieceNPlocal>) pieceDonjon.clone();
|
||
|
this.indexPiecePerso = positionDepart;
|
||
|
}
|
||
|
|
||
|
public PieceNPlocal apres (PieceNPlocal p){
|
||
|
if (indexPiecePerso+1>=donjon.size()){
|
||
|
return this.donjon.get(0);
|
||
|
}
|
||
|
else{
|
||
|
return this.donjon.get(indexPiecePerso+1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public PieceNPlocal avant (PieceNPlocal p){
|
||
|
if (indexPiecePerso-1<0){
|
||
|
return this.donjon.get(this.donjon.size()-1);
|
||
|
}
|
||
|
else{
|
||
|
return this.donjon.get(indexPiecePerso-1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void persoAvance(){
|
||
|
this.indexPiecePerso++;
|
||
|
}
|
||
|
|
||
|
public void persoRecule(){
|
||
|
this.indexPiecePerso--;
|
||
|
}
|
||
|
|
||
|
}
|