0

ok this will not work what im trying to do is create a game where you are a miner and need to put mines in 5 different spots im about 1/3 done but i cant get the money to come in after i build the mine i have gone through it three times maby one of yuo could help

code:

#include <iostream>
using namespace std;
int main() {
    int Y; // up-down
    int X; //left-right
    int STATION;
    int MINE;
    int YOU;
    int SCAN;
    int FUEL;
    int SEL;
    int MONEY;
    int TCOUNTER;
    
    
    MONEY = 10000;
    if (MONEY = 10000){
              cout<<"money corect\n";
    }
    else{
         MONEY = 10000;
    }
    cout<<"checking int...\n";     //////////////
    Y = 50;                        // checking //
    X = 50;                        //////////////
    if (Y == 50){
          cout<<"y corect\n";
    }
    else {
         Y = 50; //setting  int
    }
    if (X == 50){ // checking int
          cout<<"x corect\n";
    }
    else {
         X = 50; //resetting int
    }
    FUEL=10;
    if (FUEL == 10){
             cout<<"fuel corect\n";
    }
    else {
         FUEL=10;
         cout<<"fuel correct\n";
    }
    STATION = 1; //at 50,50
    if (STATION == 1){
                cout<<"station corect\n";
    }
    else {
         STATION = 1;
         cout<<"station corect\n";
    }
    while (STATION == 1){
          //------------------------------------------------------------------------------
          if (MINE == 1){
                   cout<<"you have sucessfully mined 2metric tones of\n mixed rock coal and dirt!\n";
                   cout<<"you sold the mixed dirt for 200$!";
                   MONEY = MONEY+120;
                   cout<<"taxes and gas out of 200 - 80 = 120\n";
                   }
          if (MINE == 2){
                   cout<<"you have sucessfully mined 4metric tones of\n mixed rock coal and dirt!\n";
                   cout<<"you sold the mixed dirt for 400$!";
                   MONEY = MONEY+240;
                   cout<<"taxes and gas out of 400 - 160 = 240\n";
                   }
           if (MINE == 3){
                   cout<<"you have sucessfully mined 6metric tones of\n mixed rock coal and dirt!\n";
                   cout<<"you sold the mixed dirt for 600$!";
                   MONEY = MONEY+370;
                   cout<<"taxes and gas out of 600 - 230 = 270\n";
                   }
            if (MINE == 4){
                   cout<<"you have sucessfully mined 8metric tones of\n mixed rock coal and dirt!\n";
                   cout<<"you sold the mixed dirt for 800$!";
                   MONEY = MONEY+480;
                   cout<<"taxes and gas out of 800 -  = 240\n";
                   }
          
//------------------------------------------------------------------------------
          cout<<"you are at---"<< Y <<"-"<< X <<"\n";
          cout<<" 1=up 2=down 3=left 4=right 5=scan 6=skip 7=BUY-fuel 8=create sml mine\n9=create research lab 10=create refiner\n\n"; //choices
          cin>>SEL;
//------------------------------------------------------------------------------
          if (SEL == 1){    //selection
                  Y = Y+1; //stating NEW int
                  if (Y > 100){  //checking not greater than 100
                        cout<<"A sign clearley states :NO TRESSPASSING!: in big BOLD letters!\n";
                        Y = Y-1;
                  }
                  else {
                       cout<<"you have moved to" << Y << "-" << X <<"\n";
                       FUEL = FUEL-1;
                       cout<<"your current fuel level is="<<FUEL<<"0%\n";
                       }
                  }
//------------------------------------------------------------------------------
          if (SEL == 2){
                  Y = Y-1; //stating NEW int
                  if (Y < 0){ //checking no lesser than 0
                        cout<<"A sign clearley states :NO TRESSPASSING!: in big BOLD letters!\n";
                        Y = Y+1;
                        FUEL = FUEL+1;
                        }
                  else {
                       cout<<"you have moved to" << Y << "-" << X <<"\n";
                       FUEL = FUEL-1;
                       cout<<"your current fuel level is="<<FUEL<<"0%\n";
                       }
                  }
//------------------------------------------------------------------------------
          if (SEL == 3){
                  X = X-1; //stating NEW int
                  if (X < 0){  //checking not greater than 100
                        cout<<"A sign clearley states :NO TRESSPASSING!: in big BOLD letters!\n";
                        X = X-1;
                  }
                  else {
                       cout<<"you have moved to" << Y << "-" << X <<"\n";
                       FUEL = FUEL-1;
                       cout<<"your current fuel level is="<<FUEL<<"0%\n";
                       }
                  }
//------------------------------------------------------------------------------
          if (SEL == 4){
                  X = X + 1;
                  if (X > 100){  //checking not greater than 100
                        cout<<"A sign clearley states :NO TRESSPASSING!: in big BOLD letters!\n";
                        X = X-1;
                  }
                  else {
                       cout<<"you have moved to" << Y << "-" << X <<"\n";
                       FUEL = FUEL-1;
                       cout<<"your current fuel level is="<<FUEL<<"0%\n";
                       }
                  }
//------------------------------------------------------------------------------
          if (SEL==5){                             //                       1             2          3           4             5
                      cout<<" there is 5 possibel mine spots they are at\n X-55 Y-52\n X-72 Y-75 \n X-32 U-45\n X-10 Y-34\n X-72 Y-12\n";
                      }
//------------------------------------------------------------------------------
          if (SEL==6){
                      cout<<"SKIPPING\n";
                      }
//------------------------------------------------------------------------------
          if (SEL==7){
                      cout<<"BUYING FUEL...\n";
                      FUEL = 10;
                      MONEY = MONEY-100;
                      cout<<"you curently have="<<MONEY<<"$\n";
                      }
//------------------------------------------------------------------------------
          if (SEL==8){
                      if (Y==55){  //1
                                 if(X==52){
                                           cout<<"you built a small mine 3 turns remaning!\n";
                                           MINE=MINE+1;
                                           MONEY = MONEY-1000;
                                           cout<<"your current money is="<<MONEY<<"\n";
                                           }
                                 }
                      if (Y==72){//2
                                 if(X==75){
                                           cout<<"you built a small mine 3 turns remaning!\n";
                                           MINE=MINE+1;
                                           MONEY = MONEY-1000;
                                           cout<<"your current money is="<<MONEY<<"\n";
                                           }
                                 }
                      if (Y == 32){//3
                                 if(X == 45){
                                           cout<<"you built a small mine 3 turns remaning!\n";
                                           MINE=MINE+1;
                                           MONEY = MONEY-1000;
                                           cout<<"your current money is="<<MONEY<<"\n";
                                           }
                                 }
                      if (Y==10){//4
                                 if(X==34){
                                           cout<<"you built a small mine 3 turns remaning!\n";
                                           MINE=MINE+1;
                                           MONEY = MONEY-1000;
                                           cout<<"your current money is="<<MONEY<<"\n";
                                           }
                                 }
                      if (Y==72){
                              if (X==12){
                                          cout<<"you built a small mine 3 turns remaning!\n";
                                          MINE=MINE+1;
                                          MONEY = MONEY-1000;
                                          cout<<"your current money is="<<MONEY<<"\n";
                                          }
                                } 
                      else {
                           cout<<"you were unable to build the mine! there is no valid resource...\n";
                           }
          }
}
}

-kbcubs-

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by Dave Sinkula
0
if ( MONEY = 10000 )

Perhaps you are inadvertently doing what you might not want to: = is assignment, == is comparison.

if ( MINE == 1 )

Make sure MINE is assigned something in all branches before moving on. Perhaps initialize it on declaration.

Also consider a switch statement instead of a long string of ifs. And consider function to do the contents of each block.

Using cin for number input may be problematic -- consider taking user input as a string and then converting to a numeric value.

Avoid "magic" numbers. Given them a name via #define, const, or perhaps array index, or even character literal.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.