#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;

/* so the goal i want to achive is that i want the questions to give a score which will be read into main where it then will be
written into a .txt file that later on can be loaded as a highscore/scoreboard (problem i have atm is that i dunno where to put the ofstream and how to make it save the
                                                                                current score into a .txt getting confused with so many functions :P)*/


int secondq(/*int, int*/);// questions
int thirdq(/*int*/);// questions
int fourthq(/*int*/);// questions
int fifthq(/*int*/);// questions
int sixthq(/*int*/);// questions
int seventhq(/*int*/);// questions
int eigthq(/*int*/);// questions
int ninethq(/*int*/);// questions
int tenthq(/*int*/);// questions


/*struct answers{
int score;
};*/

int main()
{

    ifstream loadscores;
    //string exitchoice;
    string choice2; // to have the choice to go back to menu or restart once u fail
    bool exit = true;
    int choice; // for the switch
    //int loadscores; // for the ifstream to scoreboard
    string answer, line;
    do{
    //while(exit = true){
    cout << "MENU\n1. Start Game\n2. Load scoreboard\n3. exit\n";
    cin >> choice;
    //}while(exit); //uncomment this line to see what purpose i want the other exit = false to do remember to make the other while on line 101 a comment before
    switch(choice){
    case 1:
    //int points;
    //int score[10];
    cout << "WELCOME TO THE CISCO QUIZ  GOOD LUCK\n(do not write anything in numbers on any question only letters!!!\nThis quiz is case-sensitive please do only use capitalized letters when there\nare multiple words for example\n YouAreAmazing)\n\n\n" << endl;
    cout << "how many layers are there in the OSI model?\nA - four\nB - five\nC - seven\n";
    getline(cin, answer);
    if (answer == "c")
    {
        ofstream answers;
        char scoresheet[256]=("score.txt");
        answers.open(scoresheet, ios::app);
        //points = secondq(score[1]);
        cout<<"That is correct!\n\n";
       cout << "Your score is 5\n";
       int score;
       score = 5;
       answers <<"score: "<< score <<"\n";
       secondq(/*nextq*/);
        answers.close();
       //score += secondq(); //meant to get the return value of score havent figured this out completely coz I want it to return the value of the current question and not just from secondq which is why i also added all those ints in the first prototype

    }
    else
    {
        cout<<"That is incorrect!\n type one to restart or type two to exit\n\n";
        cin >> choice2;
        if (choice2 != "one"){
        exit = false;
    }
}
    break;

    case 2:

        loadscores.open("score.txt");
        if (loadscores.is_open())
                 {
                  while ( loadscores.good() )
                  {
                      int x = 1;
                      for (int i; i<=x; i++){
                   getline (loadscores,line);
                           cout << line << endl;}
                           cout << "do you wish to return to the menu? type one else type two to exit number" << endl;
                           cin >> choice2;
                       if (choice2 != "one"){
                                    exit = false; // need help to fix this it wont exit the pogram nor go back to the menu same with the ones beneath...
                                    }
}
        }
        loadscores.close();
        break;

   case 3:
    exit = false;
    break;


}
}while(exit);
return 0;
}

int secondq(/*int score[1], int q1*/)
{
    string answer, choice2;
    cout << "what is the short name of open shortest path first?\nA - Open Shortest Path First\nB - Online Shooting Pro Fishing\nC - Open Short Path First\n";
    getline(cin, answer);
    if (answer == "a")
    {
       ofstream answers;
        answers.open("score.txt", ios::app);
       cout<<"That is correct!\n\n";
       cout << "Your score is 10\n";
       int score;
       score = 10;
       answers <<"score: "<< score <<"\n";
        answers.close();
        //return score1;
       thirdq();


    }
    else
    {
        cout<<"That is incorrect!\n type one to restart or type two to go to menu\n\n";
        cin >> choice2;
        if (choice2 == "two"){
        //exit = true;
    }
}
}
int thirdq()
{
    string answer, choice2;
    cout << "What does TTL mean?\nA - Twin Twitched Life\nB - Two Time Lives\nC - Time To Live\n";
    getline(cin, answer);
    if (answer == "c")
    {
        ofstream answers;
        answers.open("score.txt", ios::app);
       cout<<"That is correct!\n";
       cout << "Your score is 15\n\n";
       int score;
       score = 15;
       answers <<"score: "<< score <<"\n";
        answers.close();
       fourthq();

    }
    else
    {
        cout<<"That is incorrect!\n type one to restart or type two to go to menu\n\n";
        cin >> choice2;
        if (choice2 == "two"){
        //exit = true;
    }
}
}
int fourthq()
{
    string answer, choice2;
    cout << "What is the first command you enter on a Cisco router?\nA - Enter\nB - Enable\nC - Disable\n";
    getline(cin, answer);
    if (answer == "b")
    {
        ofstream answers;
        answers.open("score.txt", ios::app);
       cout<<"That is correct!\n";
       cout << "Your score is 20\n\n";
       int score;
       score = 20;
       answers <<"score: "<< score <<"\n";
        answers.close();
        fifthq();

    }
    else
    {
        cout<<"That is incorrect!\n\n type one to restart or type two to go to menu\n\n";
        cin >> choice2;
        if (choice2 == "two"){
        //exit = true;
    }
}
}
int fifthq()
{
    string answer, choice2;
    cout << "which protocol is the most prefered one?\nA - rip\nB - ripv2\nC - ospf?\n";
    getline(cin, answer);
    if (answer == "c")
    {
        ofstream answers;
        answers.open("score.txt", ios::app);
       cout<<"That is correct!\n";
       cout << "Your score is 25\n\n";
       int score;
       score = 25;
       answers <<"score: "<< score <<"\n";
        answers.close();
       sixthq();

    }
    else
    {
        cout<<"That is incorrect!\n\n type one to restart or type two to go to menu\n\n";
        cin >> choice2;
        if (choice2 == "two"){
        //exit = true;
    }
}
}
int sixthq()
{
    string answer, choice2;
    cout << "You are using OSPF as protocol, replace the dots\nnetwork 192.168.1.0 0.0.0.255 .... 0\n";
    getline(cin, answer);
    if (answer == "area")
    {
        ofstream answers;
        answers.open("score.txt", ios::app);
       cout<<"That is correct!\n";
       cout << "Your score is 30\n\n";
       int score;
       score = 30;
       answers <<"score: "<< score <<"\n";
        answers.close();
       seventhq();

    }
    else
    {
        cout<<"That is incorrect!\n type one to restart or type two to go to menu\n\n";
        cin >> choice2;
        if (choice2 == "two"){
        //exit = true;
    }
}
}
int seventhq()
{
    string answer, choice2;
    cout << "Which subnet address has not been subnetted?\n A - 192.168.1.2 255.255.255.228 \n B - 172.16.1.2 255.255.255.0 \n C - 192.168.1.2 255.255.255.0\n D - 10.10.10.10 255.128.0.0. (answer with a, b ,c or d)\n";
    getline(cin, answer);
    if (answer == "c")
    {
        ofstream answers;
        answers.open("score.txt", ios::app);
       cout<<"That is correct!\n";
       cout << "Your score is 35\n\n";
       int score;
       score  = 35;
       answers <<"score: "<< score <<"\n";
        answers.close();
       eigthq();

    }
    else
    {
        cout<<"That is incorrect!\n\n type one to restart or type two to go to menu\n\n";
        cin >> choice2;
        if (choice2 == "two"){
        //exit = true;;
    }
}
}
int eigthq()
{
    string answer, choice2;
    cout<<"What is EIGRP short for?\n";
    getline(cin, answer);
    if (answer == "EnhancedInteriorGatewayRoutingProtocol")
    {
        ofstream answers;
        answers.open("score.txt", ios::app);
       cout<<"That is correct!\n";
       cout << "Your score is 40\n\n";
       int score;
       score = 40;
       answers <<"score: "<< score <<"\n";
        answers.close();
       ninethq();
    }
    else
    {
        cout<<"That is incorrect!\n\n type one to restart or type two to go to menu\n\n";
        cin >> choice2;
        if (choice2 == "two"){
        //exit = true;
    }
}
}

int ninethq()
{
    string answer, choice2;
    cout<<"Who came out with ios first?";
    getline(cin, answer);
    if (answer == "cisco")
    {
        ofstream answers;
        answers.open("score.txt", ios::app);
       cout<<"That is correct!\n";
       cout << "Your score is 45\n\n";
       int score;
       score = 45;
       answers <<"score: "<< score <<"\n";
        answers.close();
       tenthq();

    }
    else
    {
        cout<<"That is incorrect!\n\n type one to restart or type two to go to menu\n\n";
        cin >> choice2;
        if (choice2 == "two"){
        //exit = true;
    }
}
}
int tenthq()
{
    string answer, choice2;
    cout<<"\n\n";
    getline(cin, answer);
    if (answer == "youtube")
    {
        ofstream answers;
        answers.open("score.txt", ios::app);
       cout<<"That is correct!\n\n\n";
       cout << "Your score is 50\n\n";
       int score;
       score = 50;
       answers <<"score: "<< score <<"\n";
        answers.close();
    }
    else
    {
        cout<<"That is incorrect!\n\\n type one to restart or type two to go to menu\n\n";
        cin >> choice2;
        if (choice2 == "two"){
        //exit = true;
    }
}
}
/*int question(int score){
int a;
a = score + 5;
return a;
}*/ /*  this is a function or a sort of function that i was making to add
all the diffrent questions scores together and then return a sum of that into score ignore this one for now if u cant fidn any purpose of it */
