package chords.expression;
import static chords.util.Escala.getNotaEscalaBemol;
import static chords.util.Escala.getNotaEscalaSustenido;
public class ExpNth extends Nota {
public ExpNth(Nota nota, String nth) {
super(nota, nth);
}
@Override
public boolean checaNota() {
return true;
}
@Override
public String getFormacaoDaNota() {
Nota notaBase = getNotaBase();
int posicaoNth = posicaoNth();
String nthNota;
while (true) {
if (notaBase instanceof ExpNota || notaBase instanceof ExpSustenido) {
String nota = notaBase.getNota();
nthNota = getNotaEscalaSustenido(nota, posicaoNth);
break;
} else if (notaBase instanceof ExpBemol) {
String nota = notaBase.getNota();
nthNota = getNotaEscalaBemol(nota, posicaoNth);
break;
}
notaBase = notaBase.getNotaBase();
}
return getNotaBase().getFormacaoDaNota() + " - " + nthNota;
}
public int posicaoNth() {
int nth = Integer.valueOf(getVariacao());
switch (nth) {
case 2:
return 2;
case 4:
return 5;
case 6:
return 9;
case 9:
return 2;
case 11:
return 5;
case 13:
return 9;
default:
return 0;
}
}
}