import java.util.Scanner;
class Fraction {
int fenzi;
int fenmu;
Fraction(int a,int b){
this.fenzi = a;
this.fenmu = b;
}
void print(){
System.out.println(fenzi+"/"+fenmu);
}
Fraction plus(Fraction r){
r.fenzi = r.fenzi*this.fenmu + this.fenzi*r.fenmu;
r.fenmu = r.fenmu * this.fenmu;
return r;
}
Fraction multiply(Fraction r){
r.fenzi = r.fenzi * this.fenzi;
r.fenmu = r.fenmu * this.fenmu;
return r;
}
public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner in = new Scanner(System.in);
Fraction a = new Fraction(in.nextInt(),in.nextInt());
Fraction b = new Fraction(in.nextInt(),in.nextInt());
a.print();
b.print();
a.plus(b).print();
a.multiply(b).plus(new Fraction(5,6)).print();
a.print();
b.print();
in.close();
}
}
函数plus我想做的事两个分数相加,请问是哪里错了 函数里的this.分母是a的分母还是r得分母