All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.stamp.botsing.Fraction Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package eu.stamp.botsing;

public class Fraction {

    int numerator;
    int denominator;

    public Fraction(int numerator, int denominator){
        this.numerator = numerator;
        this.denominator = denominator;
    }

    public double getValue(){
        if (denominator == 0) {
            throw new IllegalArgumentException();
        }
        return ((double) this.numerator)/this.denominator;
    }

    public double getShiftedValue(int shift){
        if (denominator == 0) {
            throw new IllegalArgumentException();
        }
        return this.numerator/(this.denominator + shift);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy