import java.util.*; public class DonjonNPlocal extends Donjon{ private int indexPiecePerso; private ArrayList donjon; public DonjonNPlocal (ArrayList pieceDonjon, int positionDepart){ this.donjon = (ArrayList) 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--; } }