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

io.github.osamabmaq.tafqeetj.converters.ThreeDigitsNumberDisassembler Maven / Gradle / Ivy

Go to download

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy