
public class FileDAttente {
	private Client[] clientsPossibles;
	private int premierePlaceLibre;

	FileDAttente() {
		this.clientsPossibles = new Client[10];
		this.premierePlaceLibre = 0;
	}

	int getTaille() {
		int cpt = 0;
		for(int i = 0; i < this.clientsPossibles.length; i++) {
			if(this.clientsPossibles[i] != null) {
				cpt++;
			}
		}
		return cpt;
	}

	int getTaille2() {
		return this.premierePlaceLibre;
	}

	boolean ajouterClient(Client x) {
		for(int i = 0; i < this.clientsPossibles.length; i++) {
			if(this.clientsPossibles[i] == x) {
				return false;
			}
		}
		for(int j = 0; j < this.clientsPossibles.length; j++) {
			if(clientsPossibles[j] == null) {
				clientsPossibles[j] = x;
				this.premierePlaceLibre++;
				return true;
			}
		}
		return false;
	}

	boolean ajouterClient2(Client x) {
		for(int i = 0; i < this.clientsPossibles.length; i++) {
			if(this.clientsPossibles[i] == null) {
				this.clientsPossibles[i] = x;
				this.premierePlaceLibre++;
				return true;
			}
			if(this.clientsPossibles[i] == x) {
				return false;
			}
		}
		return false;
	}

	void desister(Client x) {
		for (int i = 0; i < this.clientsPossibles.length; i++) {
			if(this.clientsPossibles[i] == x) {
				this.clientsPossibles[i] = null;
				for(int k = i + 1; k < this.clientsPossibles.length; k++) {
					this.clientsPossibles[k - 1] = this.clientsPossibles[k];
				}
			}
		}
	}

	Client extraitPremier() {
		if(getTaille() == 0) {
			return null;
		}
		Client c = this.clientsPossibles[0];
		this.desister(c);
		return c;
	}

	void afficher() {
		for(int i = 0; i < this.getTaille(); i++) {
			System.out.println(
					i+1
					+ ". "
					+ this.clientsPossibles[i].getPrenom()
					+ " "
					+ this.clientsPossibles[i].getNom());
		}
	}

}