0

他のプログラムを正常にコンパイル/実行しましたが、以下のコードをコンパイル/実行しようとすると、「このプロジェクトはまだビルドされていません。今ビルドしますか?」と表示されます。

関数 getWinnings() から int b を取り出すとコンパイル/実行されますが、引数をさらに追加すると code::blocks が上記のメッセージを表示します。これは何が原因ですか?

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

    int gameCoins;

    using namespace std;

    void instructions();
    void playSlots();
    void spin();

    int main()
    {
    srand(time(NULL));
    instructions();
    playSlots();
    }

    void instructions()
    {
    cout << "\t\t" << "VIRTUAL SLOT MACHINE" << "\n\n";
    cout << "INSTRUCTIONS: " << endl << "You start with 500 coins. The game is over either when you run out of coins or you quit the game." << "\n";
    cout << "It will cost you 25 coins per spin. Good luck!" << "\n\n" ;
    }
    void playSlots()
    {
    string user_input;
    string replay_or_quit;

    while (replay_or_quit != "n" && replay_or_quit != "no")
    {
    gameCoins = 500;
    cout << "Coins: " << gameCoins << "\n";
    while (user_input != "spin" && user_input != "Spin")
    {
        cout << "Spin the wheels to start playing. Type 'spin' to begin" << "\n";
        cin >> user_input; cout << "\n\n";
    }
    spin();
    while (gameCoins > 0 && user_input != "no" && user_input != "n")
    {
        cout << "Spin again?" << "\n" << "Decision: ";
        cin >> user_input;
        if (user_input == "y" || user_input == "yes")
        spin();
    }
    if (gameCoins == 0)
    {
        cout << "You went broke. Play again?" << "\n" << "Decision: ";
        cin >> replay_or_quit;
    }
    else
    {
        cout << "Congratulations, you won " << gameCoins << " coins. Play again?" << "\n" << "Decision: ";
        cin >> replay_or_quit;
    }
}
}

    int getWinnings(int a, int b)
    {
    return (a+b);
    }
    void spin()
    {
int wheelOne_Top, wheelOne_Mid, wheelOne_Bot;
int wheelTwo_Top, wheelTwo_Mid, wheelTwo_Bot;
int wheelThree_Top, wheelThree_Mid, wheelThree_Bot;
int coinsWon;

gameCoins = gameCoins-25;
wheelOne_Top = (rand() % 3) + 1, wheelTwo_Top = (rand() % 3) + 1, wheelThree_Top = (rand() % 3) + 1;
wheelOne_Mid = (rand() % 3) + 1, wheelTwo_Mid = (rand() % 3) + 1, wheelThree_Mid = (rand() % 3) + 1;
wheelOne_Bot = (rand() % 3) + 1, wheelTwo_Bot = (rand() % 3) + 1, wheelThree_Bot = (rand() % 3) + 1;

while (wheelOne_Top == wheelOne_Mid || wheelOne_Top == wheelOne_Bot || wheelOne_Bot == wheelOne_Mid)
{
    wheelOne_Mid = (rand() % 3) + 1;
    wheelOne_Bot = (rand() % 3) + 1;
}
while (wheelTwo_Top == wheelTwo_Mid || wheelTwo_Top == wheelTwo_Bot || wheelTwo_Bot == wheelTwo_Mid)
{
    wheelTwo_Mid = (rand() % 3) + 1;
    wheelTwo_Bot = (rand() % 3) + 1;
}
while (wheelThree_Top == wheelThree_Mid || wheelThree_Top == wheelThree_Bot || wheelThree_Bot == wheelThree_Mid)
{
    wheelThree_Mid = (rand() % 3) + 1;
    wheelThree_Bot = (rand() % 3) + 1;
}

cout << "Coins: " << gameCoins << endl << endl;
cout << "\t\t\t" << wheelOne_Top << " " << wheelTwo_Top << " " << wheelThree_Top << "\n";
cout << "\t\t\t" << wheelOne_Mid << " " << wheelTwo_Mid << " " << wheelThree_Mid << "\n";
cout << "\t\t\t" << wheelOne_Bot << " " << wheelTwo_Bot << " " << wheelThree_Bot << "\n\n";

coinsWon = getWinnings(wheelOne_Top, wheelOne_Mid);
gameCoins = coinsWon + gameCoins;

if (gameCoins > 0)
    cout << "You won " << gameCoins << " coins!" << "\n" << "Total Coins: " << gameCoins << "\n\n";
else
    cout << "You lost 25 coins!" << "\n" << "Total coins: " << gameCoins << "\n\n";
}
4

2 に答える 2