Hallo,
ich habe ein Verständnisproblem:
hier eine kalsse Complex
und hier die Texst Klasse:
ich muss die entsprechende methoden implementieren und ich verstehe nicht ganz was da zurückgegebn wird mit return new Complex(). Weiss einer das?
danke
ich habe ein Verständnisproblem:
hier eine kalsse Complex
Java:
class Complex {
private double real, imag;
Complex() {}
Complex(double real, double imag) {
this.real = real;
this.imag = imag;
}
Complex(Complex other) {
this.real = other.real;
this.imag = other.imag;
}
public Complex add (Complex other) {
return new Complex();
}
public Complex sub (Complex other) {
return new Complex();
}
public Complex mul (Complex other) {
return new Complex();
}
public Complex div (Complex other) {
return new Complex();
}
public Complex con () {
return new Complex ();
}
Java:
public class TestComplex {
public static void main(String args[]) {
Complex a = new Complex(3, 4);
Complex b = new Complex(2, 3);
System.out.println(a.add(b));
System.out.println(b.sub(a));
System.out.println(a.mul(b));
System.out.println(a.div(b));
System.out.println(a.mul(a.con()));
}
}
danke