package com.example.springip.lab2.domains;

import com.example.springip.lab2.domains.OperationInterface;
import org.springframework.stereotype.Component;

@Component(value = "num")
public class OperationNumImpl implements OperationInterface<Integer> {
    @Override
    public Integer sum(Integer o, Integer o2) {
        return o + o2;
    }

    @Override
    public Integer mul(Integer o, int num) {
        return o * num;
    }

    @Override
    public int length(Integer o) {
        int n = o;
        int k = 0;
        while (n % 10 != 0) {
            n /= 10;
            k++;
        }
        return k;
    }

    @Override
    public boolean startsWith(Integer o, Integer symb) {
        return o % (Math.pow(10,length(symb))) == symb;
    }
}
