Untitled
unknown
plain_text
2 years ago
706 B
12
Indexable
class Complejo{
private double real;
private double imag;
Complejo(){
this(0,0);
}
Complejo(double real, double imag){
this.real=real;
this.imag=imag;
}
void setReal(double real){
this.real=real;
}
double getReal(){
return this.real;
}
void setImag(double imag){
this.imag=imag;
}
double getImag(){
return imag;
}
Complejo sumar(Complejo b){
return new Complejo(this.real+b.real, this.imag+b.imag);
}
public String toString(){
return this.real+ (this.imag>=0?" + "+this.imag+"i": " "+this.imag+"i") ;
}
}Editor is loading...