#include <iostream>
#include <map>
using namespace std;

// this file available at: https://arachnoid.com/files/python01/

enum States
{
    HUNGRY,
    TIRED,
    RESTLESS,
    ERRORSTATE,
};

void using_switch(int state)
{
    switch (state)
    {
        case States::HUNGRY:
        {
            printf("\tFeeling hungry\n");
            break;
        }
        case States::TIRED:
        {
            printf("\tNeed to sleep\n");
            break;
        }
        case States::RESTLESS:
        {
            printf("\tMaybe a hike\n");
            break;
        }
        case States::ERRORSTATE:
        {
            printf("\tError: Unknown state\n");
            break;
        }
    };
};

std::map<States, std::string> statemap = {
    {HUNGRY, "\tFeeling hungry\n"},
    {TIRED, "\tNeed to sleep\n"},
    {RESTLESS, "\tMaybe a hike\n"},
    {ERRORSTATE, "\tError: Unknown state\n"},
};

void using_map(int state)
{
    auto p = States(state);
    std::string s = statemap.at(p);
    printf("%s", s.c_str());
};

typedef void (*Functions)(int state);

Functions functions[] = {
    using_switch,
    using_map,
};

std::string function_names[] = {
    "using_switch",
    "using_map",
};

int main(int argc, char **argv)
{
    printf("Example Program Flow: C++\n");
    for (int i = 0; i < 2;i++)
    {
        Functions &function = functions[i];
        std::string &name = function_names[i];
        printf("Function: %s(int state)\n", name.c_str());
        for (int state = States::HUNGRY; state <= States::ERRORSTATE; state++)
        {
            function(state);
        }
    }
};