#include <stdlib.h>
#include <stdio.h>

#include "Exceptions.h"

GeneralException::GeneralException(char* _message) {
    message = _message;
}

void GeneralException::displayMessage() {
    printf("%s\n", message);
}

SumProbabilitiesException::SumProbabilitiesException(double _sum) : GeneralException(" > ERROR! The sum of probabilities of all scenarios doesn't equal one!") {
    sum = _sum;
}

void SumProbabilitiesException::displayMessage() {
    GeneralException::displayMessage();
    printf(" > The sum is %f != 1.\n", sum);
}

NumParametersException::NumParametersException() : GeneralException(" > ERROR! The number of parameters is not the same for all scenarios.") {

}

FileNotExists::FileNotExists(char* _fileName) : GeneralException(" > ERROR! I cannot open the given file!") {
    fileName = _fileName;
}

void FileNotExists::displayMessage() {
    GeneralException::displayMessage();
    printf(" >> The file '%s' probably doesn't exist.\n", fileName);
}

NoOccurenceOfVariableInLSTFile::NoOccurenceOfVariableInLSTFile(char* _nameOfVariable, char * _fileName) : GeneralException(" > ERROR! The following variable doesn't exist in a given file!") {
    nameOfVariable = _nameOfVariable;
    fileName = _fileName;
}

void NoOccurenceOfVariableInLSTFile::displayMessage() {
    GeneralException::displayMessage();
    printf(" >> The variable: '%s' in the file: '%s'\n", nameOfVariable, fileName);
}

