#include <iostream>
#include <cstring>
#include <math.h>


using namespace std;

bool igualMenor(float a, float b, float epsilon){
    if (fabs(a-b) < epsilon) return true;

    return a-b < 0;
}

bool igualMaior(float a, float b, float epsilon){
    if (fabs(a-b) < epsilon) return true;

    return a-b > 0;
}

class cVarFloat
{
private:
       float            fValue;
       float            fValueSet;
       float            fMax;
       float            fMin;
       char             ItemText[100];
public:
       float            GetMax()
       {
           return this->fMax;
       }

       float            GetValue()
       {
           return this->fValue;
       }

       char*            GetItemText(void)
       {
           return this->ItemText;
       }

       void         SetValue(float fValue)
       {
           this->fValue = fValue;
       }

       /*
           É nessa função que eu estou tendo o problema
       */
       void         DecValue(void)
       {
           if (igualMenor(this->fValue, this->fMin, 0.0001))
               this->fValue = this->fMax;
           else
               this->fValue -= this->fValueSet;
       }

       void         IncValue(void)
       {
           if (igualMaior(this->fValue, this->fMax, 0.0001))
               this->fValue = fMin;
           else
               this->fValue += fValueSet;
       }

       cVarFloat(const char* ItemText, float fMin, float fMax, float fValueSet, float fInitValue)
       {
           this->fMin = fMin;
           this->fMax = fMax;
           this->fValueSet = fValueSet;
           this->fValue = fInitValue;
           strcpy(this->ItemText, ItemText);
       }
   };

int main()
{
    // Primeiro argumento = Texto da classe
    // Segundo argumento = Valor mínimo
    // Terceiro argumento = Valor máximo
    // Quarto argumento = Valor na qual vai aumentar/diminuir o valor da variável
    // Quinto argumento = Valor inicial da variável

    cVarFloat Teste("Testando um float", 0.0f, 0.5f, 0.1f, 0.5f);

	cout<<fixed;

	int opcao = 1;

    while (opcao != 3)
    {
        cin>>opcao;
        
        if (opcao == 2)
        {
            Teste.IncValue();
            cout << "Item texto: " << Teste.GetItemText() << "\nValor maximo do item: " << Teste.GetMax() << "\nValor atual: " << Teste.GetValue() << endl << endl;
        }

        if (opcao == 1)
        {
            Teste.DecValue();   // problema nessa função
            cout << "Item texto: " << Teste.GetItemText() << "\nValor maximo do item: " << Teste.GetMax() << "\nValor atual: " << Teste.GetValue() << endl << endl;
        }
    }
    return 0;
}
