
Classes and Objects • 187
return temp;
}
complex sub(complex A, complex B)
{
complex temp = new complex();
temp.real = A.real - B.real;
temp.imag = A.imag - B.imag;
return temp;
}
void show()
{
System.out.println(real + “+j “ + imag);
}
}
class JPS29
{
public static void main(String[] args)
{
complex c1 = new complex(2.0, 3.0);
complex c2 = new complex(3.0, 2.0);
complex c3 = new complex();
complex c4 = new complex();
c3 = c1.sum(c1, c2);
c4 = c1.sub(c1, c2);
System.out.print(“\n\n C1 := “);
c1.show();
System.out.print(“ C2 := “);
c2.show();
System.out.print(“ SUM := “);
c3.show();
System.out.print(“ SUB := “); ...