Original Post
Well, uhh.. This is the first thing I've actually worked on, so I just wanted some input on it. This is a simple unit upgrade situation for a game I am working on. Instead of having a random integer for the resources it would be from the experience the unit has earned. #include #include #include using namespace std; int main() { srand(time(0)); int aliensKilled = rand() % 20 + 1; int multi = rand() % 5 +1; int score = aliensKilled * multi; //Determines if they have enough resources to upgrade.. cout << "Kills: " << aliensKilled << endl; cout << "Resources: " << score << endl; char choice; int resources = score; enum ship {FIGHTER = 0, BOMBER = 50, CRUISER = 100, DESTROYER = 200}; ship myShip = BOMBER; cout << "\nDo you want to upgrade your Bomber to a Cruiser for " << (CRUISER - myShip) << " resource points?"; cin >> choice; int newResource; switch (choice) //Choosing yes or no.. { case 'y': //If the choice is yes.. if (resources >= (CRUISER - myShip)) { newResource = ((score) - (CRUISER - myShip)); cout << "\n\nYou have upgraded to a Cruiser. \nYou now have " << newResource << " resource points."; cout << "\n\You now have a Cruiser."; cout << "\n\n\nPress the enter key to exit."; cin.ignore(cin.rdbuf()->in_avail() + 1); cin.ignore(cin.rdbuf()->in_avail() + 1); } else { cout << "\n\nYou do not have enough resources."; cout << "\nYou are left with a Bomber."; cout << "\n\n\nPress the enter key to exit."; cin.ignore(cin.rdbuf()->in_avail() + 1); cin.ignore(cin.rdbuf()->in_avail() + 1); } break; case 'n': //If choice is no.. cout << "\nYou choose not to upgrade at this time."; cout << "\nYou are left with a Bomber."; cout << "\n\n\nPress the enter key to exit."; cin.ignore(cin.rdbuf()->in_avail() + 1); cin.ignore(cin.rdbuf()->in_avail() + 1); break; } return 0; }