BUT2/DEV/DEV_Madelaine/Shadock_couliior/DonjonLocal.java

38 lines
900 B
Java
Raw Normal View History

import java.util.*;
public class DonjonLocal implements Donjon {
private List<Piece> couloir;
private int position;
public DonjonLocal() {
this.couloir = new ArrayList<>();
this.position = 0;
this.remplirCouloir(50);
}
@Override
public Piece apres() {
this.position = (this.position+1)%this.couloir.size();
return this.couloir.get(this.position);
}
@Override
public Piece avant() {
this.position = (this.position+(this.couloir.size()-1))%this.couloir.size();
return this.couloir.get(this.position);
}
@Override
public Piece ici() {
return this.couloir.get(this.position);
}
private void remplirCouloir(int nbPiece) {
int i;
for (i = 0; i < nbPiece; i++) {
Piece piece = new PieceConcrete();
this.couloir.add(piece);
}
}
}