日期:2014-05-20  浏览次数:20605 次

有个代码 请帮忙看看
class Plural 
{
private double real;
private double image;

Plural()
{

}


Plural(double real,double image)
{
this.real=real;
this.image=image;
}


public void print()
{
System.out.println( real+"+"+image+ "i");
}


public void setReal(double real)
{
this.real=real;
}
public double getReal()
{
return this.real;
}
public void setImage(double image)
{
this.image=image;
}
public double getImage()
{
return this.image;
}
public //这里返回什么 sum( Plural p)
{
double real2=p.getReal()+this.real;
double image2=p.getImage()+this.image;

}
}


class Test55
{
public static void main(String []args)
{
Plural p1 =new Plural(3.0,4.0);
p1.print();
Plural p2 =new Plural(4.0,7.0);
p1.sum(p2);

//应该怎么调用 }
}

------解决方案--------------------
Java code

public //这里返回什么 sum( Plural p)
{
double real2=p.getReal()+this.real;
double image2=p.getImage()+this.image;

}
}