Menu

Need some help!

Tivoilos
2008-08-31
2012-09-26
  • Tivoilos

    Tivoilos - 2008-08-31

    I am working on a small text based game. It has the ability to ask you one question when you get it right it says Correct, when wrong gives your incorrect etc etc.

    Now I've tryed putting in like another Question using a new function. Everytime I put in my prototype it seems not to able to understand it.

    Main.cpp
    [code]//Coded and Created by: Andrew Kapaldo (8-29-08)
    //Assisted by: Adam
    //Text Based Game

    include <iostream>

    include <cstdlib>

    include "quiz.h"

    include "int.h"

    include <stdlib.h>

    include <windows.h>

    using namespace std;

    int main()
    {
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
    //Initialzation of Program
    GameTitle();

    cout &lt;&lt; &quot;Do you wish to start a new game? (Y/N:) &quot; &lt;&lt; endl;
    char new_game = cin.get();
    new_game = toupper(new_game);
    //check to see if input is vaild before doing stuff
    while(new_game != 'Y' &amp;&amp; new_game !='N')
    {
        cout &lt;&lt; &quot;Invaild input. Enter Y or N: &quot;;
        new_game = cin.get();
        new_game = toupper(new_game);
    }
    if(new_game == 'Y')
    {
        cout &lt;&lt; &quot;Welcome to Ever Life!\n&quot;;
        QuizStart();
    
    }
    else if(new_game == 'N')
    {
        cout &lt;&lt; &quot;Have a nice day!\n&quot;;
        cout &lt;&lt; &quot;To close the program please enter C:\n&quot;;
        while (new_game != 'C'){
            new_game = cin.get();
            new_game = toupper(new_game);
    

    }
    }
    return 0;
    }[/code]

    int.h
    [code]//Coded and Created by: Andrew Kapaldo (8-29-08)
    //Assisted by: Adam

    //This is for all the Header Titles for the system

    ifndef INT_H

    define INT_H

    //Function name of Initlization
    void GameTitle();

    endif

    [/code]

    int.cpp
    [code]//Coded and Created by: Andrew Kapaldo (8-29-08)
    //Assisted by: Adam

    //Initilization of the game

    include <iostream>

    include <cstdlib>

    include "int.h"

    using namespace std;

    char int_game = 0;

    void GameTitle()
    {
    cout << "********\n"
    << "***** Ever Life **\n"
    << "
    ** Version 1 Test ****\n"
    << "********\n";
    }[/code]

    quiz.h
    [code]//Coded and Created by: Andrew Kapaldo (8-29-08)
    //Assisted by: Adam
    //Quiz Header

    ifndef QUIZ_H

    define QUIZ_H

    void QuizStart();

    void QuizStart2();

    endif

    [/code]

    quiz.cpp
    [code]//Coded and Created by: Andrew Kapaldo (8-29-08)
    //Assisted by: Adam

    //This is using the funcitons that is declared in Quiz.h

    include <iostream>

    include <cstdlib>

    include "quiz.h"

    using namespace std;

    char quiz_a = 0;
    char quiz_b = 0;

    void QuizStart(); void QuizStart2()

    {
    cout << "The quiz will start shortly!\n"
    << "\n"
    << "\n";
    cout << "Who invented the lightbulb?\n"
    << "A: Ben Franklin\n"
    << "B: Thomas Edison\n"
    << "C: George Washington\n";
    cin.get();
    quiz_a = cin.get();
    quiz_a = toupper(quiz_a);
    if (quiz_a == 'A' || quiz_a == 'C')
    {
    cout << "Sorry incorrect!\n";

    }
    else if(quiz_a == 'B')
    {
        cout &lt;&lt; &quot;Correct!\n&quot;;
        cout &lt;&lt; &quot;Please wait for the new questions to start!\n&quot;;
        cin.get();
        QuizStart2();
    

    cin.get();
    quiz_b = cin.get();
    quiz_b = toupper(quiz_b);
    if(quiz_b == 'A' || quiz_b == 'C')
    {
    cout << "Sorry incorrect!\n";
    {
    }
    }
    [/code]

     

    Related

    Code: code

    • cpns

      cpns - 2008-08-31

      That's a lot of code to wade through to find the problem you are talking about. How about you give us a short-cut by posting the Compile Log!?

      Error messages are emitted to aid diagnosis of problems, why would you not help yourself by providing that information?

      See also the "PLEASE READ BEFORE POSTING A QUESTION" thread.

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.