package Exo2;

public class Livre implements IArticle {
	private String titre;
	private double prixHT;
	private boolean pourAdultes;
	private static double taxe = 0.05;
	public Livre (String titre, boolean pourAdultes, double prixHT) {
		this.titre = titre;
		this.prixHT = prixHT;
		this.pourAdultes = pourAdultes;
	}
	@Override
	public String getTitre()  { return titre; }
	@Override
	public double getPrixHT() { return prixHT; }
	@Override
	public double getPrixTTC() { return prixHT *(1.0 + taxe); }
	public boolean getPourAdultes () { return pourAdultes; }
	@Override
	public String toString() { 
		return "Livre "+ titre + (pourAdultes? " pour adultes":" pour tous")+ " : "+getPrixTTC()+"€";
	}
	@Override
	public int getAgeMini() {
		return this.pourAdultes?18:0;
	}
	
	@Override
	public boolean equals(Object o) {
		if(o == null) {
			return false;
		}
		if(this.getClass() != o.getClass()) {
			return false;
		}
		Livre l = (Livre) o;
		return this.getTitre().equals(l.getTitre()) 
			&& this.getPrixHT() == l.getPrixHT()
			&& this.getPrixTTC() == l.getPrixTTC()
			&& this.getAgeMini() == l.getAgeMini();
	}
}
