#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;

class Fortunecookie
{
private:
   string fortune[10];
   int rand_index;
public:
   void openFortuneCookie();
   void generateNewFortune();
   Fortunecookie();  // typo
};


void Fortunecookie::generateNewFortune()
{
    rand_index = rand() %10;
}

Fortunecookie::Fortunecookie()
               : fortune{" One that would have the fruit must climb the tree",
                   " A new opportunity awaits you at the fork of the road",
                   " The early bird gets the worm, but the second mouse gets     the cheese. ",
                   " You are cleverly disguised as responsible adult.",
                   " The best things in life aren't things",
                   " Forget injuries; never forget kindnesses.",
                   " Borrow money from a pessimist. They don't expect it       back",
                   " Your good enough, strong enough and gosh darnit' people     like you",
                   " A feather in the hand is better than a bird in the     air. ",
                   " In life, you must be the water"
                  }
{
    rand_index = rand() %10;  // number between 0 and 9 
}
void Fortunecookie::openFortuneCookie()
{
    generateNewFortune();
    
    cout << " |====================================================================| \n";
    cout << " |                                                                    | \n";
    cout << " | " <<setw(2)<<rand_index+1<<"-"<<setw(63)<<fortune[rand_index]<< " |\n";
    cout << " |                                                                    | \n";
    cout << " |====================================================================| \n";
}
int main ()
{
    srand(time(0));                    // only once, at the beginning of the programme
    Fortunecookie yourfortune;         // this calls the default constructor
    //yourfortune.generateNewFortune();
    //yourfortune.Fortunecookie();       // OUCH !!
    yourfortune.openFortuneCookie();
    return 0;
}
