分数类Fraction
属性:分子分母
方法:加减乘除、比较大小
要求构造器至少两个
分数类Fraction
属性:分子分母
方法:加减乘除、比较大小
要求构造器至少两个
@Date
public class fraction{
privvate double molecular;
private double denominator;
fraction(){
}
fraction(double molecular,double denominator){
this.molecular = molecular;
this.denominator = denominator;
}
private double add(){
return this.molecular+this.denominator;
}
private double sub(){
return this.molecular-this.denominator;
}
private double mul(){
return this.molecular*this.denominator;
}
private double div(){
return this.molecular/this.denominator;
}
private double compare(){
return this.molecular>this.denominator?this.molecular:this.denominator;
}
}