/*
 * PartituraMusical.java
 *
 * Created on April 9, 2003, 7:37 AM
 */

package cib412.poo.musica;

/**
 *
 * @author  do008548
 */
public class PartituraMusical {  
    /** Holds value of property numeroNotas. */
    private int numeroNotas;
    private NotaMusical[] arreglo;
    private int ultimo =0;
    public PartituraMusical(int nNotas) {
        this.numeroNotas=nNotas;
        this.arreglo = new NotaMusical[this.numeroNotas];
    }
    /** Getter for property numeroNotas.
     * @return Value of property numeroNotas.
     */
    public int getNumeroNotas() {
        return this.numeroNotas;
    }
    public final static String ERRORAGREGAR="Tamaņo excedido";
    public void agregar(NotaMusical nota)throws Exception {
        if (this.ultimo < this.numeroNotas) {
          this.arreglo[this.ultimo] = nota; this.ultimo++;  
        } else {
           throw new Exception(ERRORAGREGAR);  
        }//if
    }
    public NotaMusical notaEn(int indice) {
       NotaMusical nota = null;
       if (indice>=0 && indice < this.numeroNotas) 
          nota = this.arreglo[indice];
       return nota;   
    }     
}
