io.github.osamabmaq.tafqeetj.converters.ThreeDigitsNumberDisassembler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TafqeetJ Show documentation
Show all versions of TafqeetJ Show documentation
A Java library to convert numbers from digital format to words format in Arabic language.
The newest version!
package io.github.osamabmaq.tafqeetj.converters;
import io.github.osamabmaq.tafqeetj.numbers.ThreeDigitsNumber;
import java.util.Objects;
public class ThreeDigitsNumberDisassembler {
private final ThreeDigitsNumber threeDigitsNumber;
public ThreeDigitsNumberDisassembler(ThreeDigitsNumber threeDigitsNumber) {
this.threeDigitsNumber = Objects.requireNonNull(threeDigitsNumber);
}
public ThreeDigitsNumber getThreeDigitsNumber(){
return threeDigitsNumber;
}
public int getHundreds() {
if (!threeDigitsNumber.containsHundreds())
throw new IllegalStateException("Number does not contain hundreds");
return (threeDigitsNumber.getNumber() / 100) * 100;
}
public int getTens() {
if (!threeDigitsNumber.containsTens())
throw new IllegalStateException("Number does not contain tens");
return ((threeDigitsNumber.getNumber() % 100) / 10) * 10;
}
public int getComposedNumber() {
if (!threeDigitsNumber.containsComposedNumber())
throw new IllegalStateException("Number does not contain composed number");
return threeDigitsNumber.getNumber() % 100;
}
public int getOnes() {
if (!threeDigitsNumber.containsOnes())
throw new IllegalStateException("Number does not contain ones");
return (threeDigitsNumber.getNumber() % 100) % 10;
}
}