io ho un mettodo aggiorna in una classe dove inserisco dei valori in una matrice di object dentro una derteminata posizione ad esempio
per visualizzare un 1 nella posizione ottava riga e 1 colonna della Jtable. ma nella fase di esecuzione non escono i risultati.
come risolvo?
questo è il metodo:
codice:
public void Aggiorna() {
double delta, d, xf, yf, yv, x1, x2, a, b, c;
int i = parabole.size();
a = parabole.get(i).getA();
b = parabole.get(i).getB();
c = parabole.get(i).getC();
tab[4][1] = 0 + "\t" + ";" + "\t" + df.format(c);
delta = parabole.get(i).getDelta();
d = parabole.get(i).getD();
xf = parabole.get(i).getXF();
yf = parabole.get(i).getYF();
yv = parabole.get(i).getYV();
tab[7][1] = "X=" + "\t" + df.format(xf);
tab[0][1] = df.format(xf) + "\t" + ";" + "\t" + df.format(yv);
tab[1][1] = df.format(xf) + "\t" + ";" + "\t" + df.format(yf);
tab[6][1] = "Y=" + "\t" + df.format(d);
if (a < 0) {
tab[9][1] = "verso il basso";
if (a == -1) {
if (b < 0) {
if (b == -1) {
if (c < 0) {
tab[8][1] = "Y=" + "-" + "x^2" + "-" + "x" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "-" + "x^2" + "-" + "x";
} else {
tab[8][1] = "Y=" + "-" + "x^2" + "-" + "x" + df.format(c);
}
} else {
if (c < 0) {
tab[8][1] = "Y=" + "-" + "x^2" + "-" + df.format(b) + "x" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "-" + "x^2" + "-" + df.format(b) + "x";
} else {
tab[8][1] = "Y=" + "-" + "x^2" + "-" + df.format(b) + "x" + df.format(c);
}
}
} else if (b == 0) {
if (c < 0) {
tab[8][1] = "Y=" + "-" + "x^2" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "-" + "x^2";
} else {
tab[8][1] = "Y=" + "-" + "x^2" + "x" + df.format(c);
}
} else {
if (c < 0) {
tab[8][1] = "Y" + "=" + "-" + "x^2" + df.format(b) + "x" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y" + "=" + "-" + "x^2" + df.format(b) + "x";
} else {
tab[8][1] = "Y" + "=" + "-" + "x^2" + df.format(b) + "x" + df.format(c);
}
}
} else {
if (b < 0) {
if (b == -1) {
if (c < 0) {
tab[8][1] = "Y=" + "-" + df.format(a) + "x^2" + "-" + "x" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "-" + df.format(a) + "x^2" + "-" + "x";
} else {
tab[8][1] = "Y=" + "-" + df.format(a) + "x^2" + "-" + "x" + df.format(c);
}
} else {
if (c < 0) {
tab[8][1] = "Y=" + "-" + df.format(a) + "x^2" + "-" + df.format(b) + "x" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "-" + df.format(a) + "x^2" + "-" + df.format(b) + "x";
} else {
tab[8][1] = "Y=" + "-" + df.format(a) + "x^2" + "-" + df.format(b) + "x" + df.format(c);
}
}
} else if (b == 0) {
if (c < 0) {
tab[8][1] = "Y=" + "-" + df.format(a) + "x^2" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "-" + df.format(a) + "x^2";
} else {
tab[8][1] = "Y=" + "-" + df.format(a) + "x^2" + df.format(c);
}
} else {
if (c < 0) {
tab[8][1] = "Y" + "=" + "-" + df.format(a) + "x^2" + df.format(b) + "x" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y" + "=" + "-" + df.format(a) + "x^2" + df.format(b) + "x";
} else {
tab[8][1] = "Y" + "=" + "-" + df.format(a) + "x^2" + df.format(b) + "x" + df.format(c);
}
}
}
if (delta < 0) {
System.out.println("nessuna soluzione reale!");
tab[5][1] = "parabola esterna";
} else if (delta == 0) {
System.out.println("due soluzioni reali e coeincidenti!");
tab[5][1] = "parabola tagente";
x1 = parabole.get(i).getX1();
x2 = x1;
tab[2][1] = df.format(x1) + "\t" + ";" + "\t" + 0;
tab[3][1] = df.format(x2) + "\t" + ";" + "\t" + 0;
} else {
System.out.println("due soluzioni!");
x1 = parabole.get(i).getX1();
x2 = parabole.get(i).getX2();
tab[5][1] = "parabola seccante";
tab[2][1] = df.format(x1) + "\t" + ";" + "\t" + 0;
tab[3][1] = df.format(x2) + "\t" + ";" + "\t" + 0;
}
} else if (a == 0) {
System.err.println("non ci sono parabole!");
} else {
delta = parabole.get(i).getDelta();
tab[9][1] = "verso l'alto";
if (a == 1) {
if (b < 0) {
if (b == -1) {
if (c < 0) {
tab[8][1] = "Y=" + "\t" + "x^2" + "\t" + "-" + "x" + "-" + "\t" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "\t" + "x^2" + "\t" + "-" + "x";
} else {
tab[8][1] = "Y=" + "\t" + "x^2" + "\t" + "-" + "x" + "\t" + df.format(c);
}
} else {
if (c < 0) {
tab[8][1] = "Y=" + "x^2" + "\t" + "-" + df.format(b) + "x" + "\t" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "x^2" + "\t" + "-" + df.format(b) + "x";
} else {
tab[8][1] = "Y=" + "x^2" + "\t" + "-" + df.format(b) + "x" + df.format(c);
}
}
} else if (b == 0) {
if (c < 0) {
tab[8][1] = "Y=" + "x^2" + "\t" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "x^2";
} else {
tab[8][1] = "Y=" + "x^2" + "\t" + df.format(c);
}
} else {
if (c < 0) {
tab[8][1] = "Y=" + "x^2" + "\t" + df.format(b) + "x" + "\t" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + "x^2" + "\t" + df.format(b) + "x";
} else {
tab[8][1] = "Y=" + "x^2" + "\t" + df.format(b) + "x" + "\t" + df.format(c);
}
}
} else {
if (b < 0) {
if (b == -1) {
if (c < 0) {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + "-" + "x" + "\t" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + "-" + "x";
} else {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + "-" + "x" + "\t" + df.format(c);
}
} else {
if (c < 0) {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + "-" + df.format(b) + "x" + "\t" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + "-" + "\t" + df.format(b) + "x";
} else {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + "-" + df.format(b) + "x" + "\t" + df.format(c);
}
}
} else if (b == 0) {
if (c < 0) {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + df.format(a) + "x^2";
} else {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + df.format(c);
}
} else {
if (c < 0) {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + df.format(b) + "x" + "\t" + "-" + df.format(c);
} else if (c == 0) {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + df.format(b) + "x";
} else {
tab[8][1] = "Y=" + df.format(a) + "x^2" + "\t" + df.format(b) + "x" + "\t" + df.format(c);
}
}
}
if (delta < 0) {
System.out.println("nessuna soluzione reale!");
tab[5][1] = "parabola esterna";
} else if (delta == 0) {
System.out.println("due soluzioni reali coeicidenti!");
x1 = parabole.get(i).getX1();
x2 = x1;
tab[5][1] = "parabola tagente";
tab[2][1] = df.format(x1) + "\t" + ";" + "\t" + 0;
tab[3][1] = df.format(x2) + "\t" + ";" + "\t" + 0;
} else {
System.out.println("due soluzioni!");
x1 = parabole.get(i).getX1();
x2 = parabole.get(i).getX2();
tab[5][1] = "parabola seccante";
tab[2][1] = df.format(x1) + "\t" + ";" + "\t" + 0;
tab[3][1] = df.format(x2) + "\t" + ";" + "\t" + 0;
}
}
}
questo è l'errore che esce:
codice:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0