+1 (315) 557-6473 

Designing a Pokedex simulator in C++ assignment help

We are required to write a program to simulate the Pokedex from the Pokemon cartoons. In the program developed by our C++ assignment help solvers, one can view the Pokemon by name, or the ones of a particular type. One can also throw Pokeballs to catch a Pokemon and keep track of the number of balls they have as well as simulate the chance of catching one.
Table Of Contents
  • Pokemon Cartoon Simulator

Pokemon Cartoon Simulator

#include #include #include #include using namespace std; struct Pokemon{ int id; string name; string type; int catchRate; int numberCaught; int numberSeen; }; int readFile(Pokemon **arr){ string filename; fstream file; do{ cout << "Enter the filename > "; getline(cin, filename); file.open(filename); } while (!file.good()); // Keep reading filename while file is not found or has some error int n,id,catchrate; string name, type; file >> n; *arr = new Pokemon[n]; for (int i = 0; i < n; i++){ file >> id >> name >> type >> catchrate; (*arr)[i] = Pokemon(); (*arr)[i].catchRate = catchrate; (*arr)[i].name = name; (*arr)[i].type = type; (*arr)[i].id = id; (*arr)[i].numberCaught = (*arr)[i].numberSeen = 0; } file.close(); return n; } void printMainMenu(){ cout << "1 - Hunt for a Pokemon!" << endl << "2 - Pokedex Statistics" << endl << "3 - Print Inventory" << endl << "4 - Show Pokemon of X type" << endl << "5 - Sort Pokemon by Name(Alphabetically)" << endl << "Q - Quit" << endl; cout << "Selection > "; } void Hunt(Pokemon*arr, int size, int&pokeBalls, int&greatBalls, int&ultraBalls){ int index = rand() % size; // number of randomly generated pokemon int selection; int rateAdded; cout << "A " << arr[index].name << " has appeared!" << endl< "; cin >> selection; cout << endl; switch (selection) { case 1: if (pokeBalls <= 0){ cout << "You have none of them!"; break; } cout << "Threw a Poke Ball!"; pokeBalls--; rateAdded = 0; exit = true; break; case 2: if (greatBalls <= 0){ cout << "You have none of them!"; break; } cout << "Threw a Great Ball!"; greatBalls--; rateAdded = 20; exit = true; break; case 3: if (ultraBalls <= 0){ cout << "You have none of them!"; break; } cout << "Threw an Ultra Ball!"; ultraBalls--; rateAdded = 40; exit = true; break; default: cout << "Invalid Selection. Try again." << endl; } cout << endl; } arr[index].numberSeen++; if ((rand() % 100) < (rateAdded + arr[index].catchRate)){ // Pokemon is caught cout << "Congratulations! You caught " << arr[index].name << "!" << endl< "; cin >> type; for (size_t i = 0; i < size; i++) { if (pokemonArr[i].type == type){ res += pokemonArr[i].name + ", "; } } if (!res.empty()){ res.pop_back(); // remove the last two unnecessary spaces res.pop_back(); cout << type << ": " << res< "; getline(cin, playerName); // print Welcome messages cout << "Welcome, "< 0 || greatBalls > 0 || ultraBalls > 0)){ printMainMenu(); cin >> choice; cout << endl; switch (choice) { case '1': Hunt(pokemonArr,size, pokeBalls, greatBalls, ultraBalls); break; case '2': PokedexStatistics(pokemonArr, size); break; case '3': cout << "You have: " << endl; cout << pokeBalls << " PokeBalls" << endl; cout << greatBalls << " greatBalls" << endl; cout << ultraBalls << " ultraBalls" << endl; cout << endl; break; case '4': showPokemonOfType(pokemonArr, size); break; case '5': sort(pokemonArr, pokemonArr + size, alphaCompare); cout << "Pokemon array has been sorted!"<