hi, I'm a new member, I've made a thread already but it just got deleted and I got an email that I shouldn't post my email adress. Actually, I don't really have any other idea besides posting my whole coding which is in different files though. The trickly part, I guess like 800 lines of coding, not so nice in a thread, that's my problem The email told me to post the relevant part, but IMO everything is relevant, I'D have to post my test class with the main and the methods it needs in the other *.java files, + the txt files it reads from.
so, the full coding is simply too much for a post IMO, I will ask step by step then.
why does onemethod work and the other one doesn't, I'll post an example.
-----------------
in my main ...
Vektor b1 = null;
try {
b1 = v1.Addition(v2);
}
catch(Exception e) {System.out.println("error");
}
System.out.println("Vek Addition: \r\n" + b1.Vektor2String(" ; "));
and the method for it from another file is ...
public Vektor Addition(Vektor b) throws Exception
{ Vektor erg = new Vektor (vektor.length);
if (vektor.length != b.vektor.length)
{ throw new Exception("different dimensions");
} // end if
for (int xi=0; xi<vektor.length; xi=xi+1)
{ erg.vektor[xi] = vektor[xi]+b.vektor[xi];
} // end for xi
return erg;
} // end Addition(Vektor b)
---------------------
now the tricky part, same thing with another method doesn't work ...
b4 = v1.Skalarprod(v2);
...
System.out.println("Vek Skalarprodukt: \r\n" + b4.Vektor2String(" ; "));
and the method ...
public double Skalarprod(Vektor b) throws Exception
{ double erg = 0;
if (vektor.length != b.vektor.length)
{ throw new Exception("different dimensions");
}
for (int xi=0; xi<vektor.length; xi=xi+1)
{ erg = erg + (vektor[xi] * b.vektor[xi]);
}
return erg;
}
so, the full coding is simply too much for a post IMO, I will ask step by step then.
why does onemethod work and the other one doesn't, I'll post an example.
-----------------
in my main ...
Vektor b1 = null;
try {
b1 = v1.Addition(v2);
}
catch(Exception e) {System.out.println("error");
}
System.out.println("Vek Addition: \r\n" + b1.Vektor2String(" ; "));
and the method for it from another file is ...
public Vektor Addition(Vektor b) throws Exception
{ Vektor erg = new Vektor (vektor.length);
if (vektor.length != b.vektor.length)
{ throw new Exception("different dimensions");
} // end if
for (int xi=0; xi<vektor.length; xi=xi+1)
{ erg.vektor[xi] = vektor[xi]+b.vektor[xi];
} // end for xi
return erg;
} // end Addition(Vektor b)
---------------------
now the tricky part, same thing with another method doesn't work ...
b4 = v1.Skalarprod(v2);
...
System.out.println("Vek Skalarprodukt: \r\n" + b4.Vektor2String(" ; "));
and the method ...
public double Skalarprod(Vektor b) throws Exception
{ double erg = 0;
if (vektor.length != b.vektor.length)
{ throw new Exception("different dimensions");
}
for (int xi=0; xi<vektor.length; xi=xi+1)
{ erg = erg + (vektor[xi] * b.vektor[xi]);
}
return erg;
}