package gestion;
import java.awt.*;

/** sous-classe de Panel comprennant les composants relatifs à une matière
 *  optionnelle ou non */
public class PanelMatiere extends Panel{
  private TextField tfnote = new TextField(10);
  private CheckboxGroup cbg = new CheckboxGroup();

  // public PanelMatiere() {}

  /** crée un Panel comportant
   *    - le nom de cette matière
   *    - les options à cocher dans le cas d'une matière optionnelle
   *    - un champ de lecture pour la valeur de la note
   */
   public PanelMatiere(Matiere matiere) {
    this.add(new Label(matiere.getNom()));
    if (matiere instanceof MatiereOptionnelle) {
      int nbOptions= ((MatiereOptionnelle)matiere).getOptions().length;
      Panel pChoix = new Panel(new GridLayout(nbOptions,1));
      cbg = new CheckboxGroup();
      for (int i=0;i<nbOptions;i++) {
       pChoix.add(
        new Checkbox(((MatiereOptionnelle)matiere).getOptions()[i], cbg,false));
        this.add(pChoix);
        }
      }
    this.add(this.tfnote);
    }

  /** renvoie le champ de lecture de ce Panel */
  public TextField getTfnote() { return this.tfnote;}

  /** renvoie le CheckboxGroup de ce Panel */
  public CheckboxGroup getCbg() {return this.cbg;}

}
