#include "Config.hpp"

#include "Calculator.hpp"

Calculator::Calculator()
{
    ready = false;
}

Calculator::Calculator(int a, int b)
{
    ready = false;

    create(a, b);
}

Calculator::~Calculator()
{
    if (valid())
    {
        destroy();
    }
}

bool Calculator::create(int a, int b)
{
    if (valid())
    {
        throw std::runtime_error("Calculator object is initialised!");
    }

    this->a = a;

    this->b = b;

    ready = !ready;

    return true;
}

bool Calculator::valid()
{
    return ready;
}

void Calculator::destroy()
{
    if (!valid())
    {
        throw std::runtime_error("Calculator object is not initialised!");
    }

    a = b = 0;

    ready = !ready;
}

int Calculator::sum()
{
    return a + b;
}

int Calculator::mul()
{
    return a * b;
}

int Calculator::diff()
{
    return a - b;
}

int Calculator::div()
{
    if (!a)
    {
        return 0;
    }

    return a / b;
}

#include "Config.hpp"

#include "Calculator.hpp"

Calculator::Calculator()
{
    ready = false;
}

Calculator::Calculator(int a, int b)
{
    ready = false;

    create(a, b);
}

Calculator::~Calculator()
{
    if (valid())
    {
        destroy();
    }
}

bool Calculator::create(int a, int b)
{
    if (valid())
    {
        throw std::exception("Calculator object is initialised!");
    }

    this->a = a;

    this->b = b;

    ready = !ready;

    return true;
}

bool Calculator::valid()
{
    return ready;
}

void Calculator::destroy()
{
    if (!valid())
    {
        throw std::exception("Calculator object is not initialised!");
    }

    a = b = 0;

    ready = !ready;
}

int Calculator::sum()
{
    return a + b;
}

int Calculator::mul()
{
    return a * b;
}

int Calculator::diff()
{
    return a - b;
}

int Calculator::div()
{
    if (!a)
    {
        return 0;
    }

    return a / b;
}

--- 
+++ 
@@ -26,7 +26,7 @@
 {
     if (valid())
     {
-        throw std::exception("Calculator object is initialised!");
+        throw std::runtime_error("Calculator object is initialised!");
     }
 
     this->a = a;
@@ -47,7 +47,7 @@
 {
     if (!valid())
     {
-        throw std::exception("Calculator object is not initialised!");
+        throw std::runtime_error("Calculator object is not initialised!");
     }
 
     a = b = 0;
Fix excepion name for linux platform.
