DEV/DEV3.4/TP6/DonjonNPlocal.java

39 lines
813 B
Java
Raw Normal View History

2023-12-15 12:28:32 +01:00
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--;
}
}