Question about my script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>

using namespace std;

int main()
{

    cout <<"Compiles Properly/n";

    //Variable Declaration
    
    int Spellcaster;
    int Fighter;
    int Crafter;
    int BaseStrength; 
   
    //Variable Assignments
   
    Spellcaster = 1;
    Fighter = 2; 
    BaseStrength >= 0;
    
    if (Spellcaster = 1)

       BaseStrength = 10;

    else
        if (Fighter = 2)

           BaseStrength = 20;
           
             return 0;
}


Okay so I have a few questions heh:

#1. I am trying to make it so that when someone picks a spell caster their base strength is 10 but if they pick a Fighter it is 20. Will this work?

#2. Am i using the correct = or should I be using == I am very new so still learning.

#3. When I compile it says it is fine but with no way of me being able to see a spell caster or a fighter I can't tell if it works heh (I know more of a statement than a question).

#4. Will i need to link this to my <base_Player.h>?

#5. Am I practicing good coding with this script? If i am not please tell me how too.

Just to let you guys know I have reading a lot here..very good articles teaching lots of good stuff. Thanks for allowing me in the community.
I think you are mistaken here
 
BaseStrength >= 0;

It's useless
@1. here some code example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#define SPELLCASTER   1
#define FIGHTER       2
using namespace std;

int main()
{
int choice;
int BaseStrength; 
cout << "What rase do you want to be?" << endl;
cout << "1. Spell Caster" << endl;
cout << "2. Fighter " << endl;
cout << "Enter you choice here: ";
cin    >> choice;                 //get users input
if(choice==SPELLCASTER) {
BaseStrenght=10;
}
else(choice==FIGHTER) {  //use == to check is it is equal... = means assignment
BaseStrenght=20;
}
else BaseStrenght = 0;

cout << "Your strenght is: " << BaseStrenght;
cin.get();
return 0;
}

@2. in if statments .. use the '==' operator... it to checks it is equal.
'=' is to asign a value to a variable.

@3. check 1..

@4. I don't know that <base_Player.h> is ... but I doubt it came with you compiler... so you can't use '<..>' to include it.. if it's a header you created put it in the same folder as the project or main file and include it like this "base_Player.h"

@5. That isn't quite a script ... You should read a little the tutorial on this website cause it will help you a lot
Last edited on
Topic archived. No new replies allowed.