Hey i just got a book called "beginning C++ through game programming" i am trying to follow trough the book and write out all of the examples to get the most out of it. anyways i havent had any trouble with any up untill this one and i have scouted for typo's or anything obvious that i may have messed up on. im using visual c++ express 2010 windows 7. and this is the code
#include <iostream>
usingnamespace std;
int main()
{
constint ALIEN_POINTS = 150;
int aliensKilled = 10;
int score = aliensKilled * ALIEN_POINTS;
cout << "score:" << score<< endl;
enum difficulty {NOVICE, EASY, NORMAL, HARD, UBEATABLE};
difficulty myDifficulty = EASY;
enum shipCost {FIGHTER_COST, BOMBER_COST, CRUISER_COST = 50};
shipCost myShipCost = BOMBER_COST;
cout << "\nTo upgrade my ship to a cruiser will cost"
<< (CRUISER_COST - myShipCost) <<" Resource Points.\n";
return 0;
}
all its supposed to do is give me a window with a score of 1500 ( 10 * ALIENS_KILLED) and tell me how may points to upgrade my ship to a "cruiser" which should be 24 CRUISER_COST - myShipCost or BOMBER_COST)
like i said i am verry new to this, this is chapter one of a book i started reading on a topic i know nothing about, so sorry if this is a noob question or if its something stupid that im missing, but any help would be great
You haven't given the bomber a value. If you give that a value it should be right. Other than that it will minus by one more than likely meaning the ship cost will be 49 instead of what you want.
score:1500
To upgrade my ship to a cruiser will cost49 Resource Points.
remember to add \n in your last cout statement so the output will be
To upgrade my ship to a cruiser will cost
49 Resource Points.
i an not sure what the problem is and it would be nice if you could elaborate more on the issue you have.
by the way, great variable naming, makes it really easy to read :).
are you just starting out or do u know all the functions/statements used in this program?
sorry so much stuff in the code brackets im not sure why im not getting this to compile correctly and not sure what you guys need to help me.
its not a matter of it opening and closing quickly, its a compiler error, i have used system("pause"); on other ones but this is also just begginer stuff im doing just to get the hang of it. my book says to run it from a batch file that i tried but that did not work either when the window closes immediatly.
i thought i did... hmm ok well that solved the issue i must have opened something wrong when creating new project. im sorry for all of the trouble everyone but thank you for all of your help