package org.initialde.yakasave.Domain.ValueObject;

import org.initialde.yakasave.Domain.Exceptions.InvalidAmountException;

public final class Amount {

    private double value;
    public static Amount ZERO = Amount.of(0.0);
    public static Amount MINIMUM_GOAL_AMOUNT = Amount.of(5000.0);
    public static Amount MINIMUM_DEPOSIT_AMOUNT = Amount.of(100.0);
    public static final Amount MINIMUM_WITH_DRAW_AMOUNT = Amount.of(100.0);


    private Amount(double value) {

        if (value < 0) {
            throw new InvalidAmountException();
        }

        this.value = value;
    }

    public static Amount of(double value) {
        return new Amount(value);
    }

    public Amount sum(Amount other) {
        return new Amount(this.value + other.value);
    }

    public void plus(Amount other) {
        this.value = sum(other).value;
    }

    public void minus(Amount other) {
        this.value -= other.value;
    }

    public boolean isGreaterThan(Amount other) {
        return value > other.value;
    }
    public boolean isEqualTo(Amount other) {
        return value == other.value;
    }

    public double toDouble() {
        return value;
    }
}
