public class Musicien { private String prenom; private String nom; private int id; private Instrument instrumentPerso; private boolean lock; /* * Constructeur par défaut */ public Musicien() { this.prenom = "None"; this.nom = "None"; } /* * Constructeur d'un musicien sans instrument */ public Musicien(String prenom, String nom, int id) { this.prenom = prenom; this.nom = nom; this.id = id; this.lock = false; } /* * Constructeur d'un musicien et de son instrument */ public Musicien(String prenom, String nom, int id, Instrument instru) { this.prenom = prenom; this.nom = nom; this.id = id; this.instrumentPerso = instru; } /*@Override public void finalize() { Main hMain = new Main(); hMain.unlock(this.instrumentPerso.id); } */ public void jouer() { if (this.instrumentPerso != null) { System.out.println(this.prenom + " " + this.nom + " joue avec son/sa " + this.instrumentPerso.getClass().getName()); this.instrumentPerso.jouer(); } else { System.out.println(this.prenom + " " + this.nom + " ne possède pas d'instrument"); } } public void accorder() { } public void setLock(boolean verrou) { this.lock = verrou; } public boolean getLock() { return this.lock; } public void sePresenter() { System.out.println("Id : " + this.id); System.out.println("Prenom : " + this.prenom); System.out.println("Nom : " + this.nom); if (this.instrumentPerso == null) { System.out.println("Pas d'instrument associé"); } else { System.out.println("Possède un/une " + this.instrumentPerso.getClass().getName()); } } public void ajouterInstrument(Instrument ins) { this.instrumentPerso = ins; } public int getInstrumentId() { return this.instrumentPerso.id; } }