In: Computer Science
C++
Please create 4 different files with this respective names
main.cpp , Pokemon.h , Pokemon.cpp Move.h
16.5 Homework 5
Introduction
Students will create a C++ program that simulates a Pokemon battle mainly with the usage of a while loop, classes, structs, functions, pass by reference and arrays. Students will be expected to create the player’s pokemon and enemy pokemon using object-oriented programming (OOP).
Scenario
You’ve been assigned the role of creating a Pokemon fight simulator between a player’s Pikachu and the enemy CPU’s Mewtwo.
You need to create a simple Pokemon battle simulation that will run until one of the pokemon’s health points (HP) reaches 0. In the simulation, the player’s Pikachu will battle the enemy Mewtwo. The Mewtwo will always be the first one to attack, then you’ll attack, and so on until the simulation ends (one of the players runs out of health points). Additionally, Mewtwo will only use one attack on the player, whereas the player's Pikachu has 3 attack options. They can either use “Thundershock”, “Quick Attack”, or “Electro Ball”. Once the battle is over, you will be greeted with the message “You win” or “You lose” depending on whether or not the player’s pokemon won the battle.
Instructions to complete the assignment
Your code must perform these major operations:
Move.h (Move Struct) Each move struct must have the following attributes:
Pokemon.h and Pokemon.cpp (Pokemon Class) Each pokemon class must have the following (pritvate) attributes:
And will have the following (public) member functions:
Thunderbolt, Electro Ball, or Quick Attack
Pokemon stats
main.cpp
In the main file, create two pokemon objects (a Mewtwo and a Pikachu) and a loop with the following sequence of actions:
Please Test the files.......
Console Input/Output
• Sample input 1
Thunderbolt Electro Ball Thunderbolt Thunderbolt
Sample output 1
Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Thunderbolt Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Electro Ball It confused Mewtwo! Thunderbolt, Electro Ball, or Quick Attack Pikachu used Thunderbolt Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Thunderbolt You win
Sample input 2
Thunderbolt Quick Attack Electro Ball Quick Attack
Sample output 2
Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Thunderbolt Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Quick Attack Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Electro Ball It confused Mewtwo! Thunderbolt, Electro Ball, or Quick Attack Pikachu used Quick Attack Mewtwo used Psycho Cut You lose
I recently started learning C++ about a week ago, and I made a bit of progress. In honor of Pokemon Go releasing, I decided to make a Pokedex with the original 151 Pokemon. So far I have 120 or so of them in there and it works PERFECTLY! (Thank goodness). I believe my code could be much more efficient and work better. I probably am using bad practices too. If I am, please feel free to tell me and if you find a problem, tell me!
Pokemon.h:
#pragma once
#include <string>
class Pokemon {
public:
std::string type;
double weight, height;
std::string Gender;
int evoLevel;
bool finalEvo;
int dexNum;
std::string name;
Pokemon(std::string name2, std::string type2, double weight2, double height2, std::string Gender2, int evoLevel2, bool finalEvo2, int dexNum2);
Pokemon();
};
Pokemon.cpp:
#include "Pokemon.h"
Pokemon::Pokemon(std::string name2, std::string type2, double weight2, double height2, std::string Gender2, int evoLevel2, bool finalEvo2, int dexNum2) {
name = name2;
type = type2;
weight = weight2;
height = height2;
Gender = Gender2;
evoLevel = evoLevel2;
finalEvo = finalEvo2;
dexNum = dexNum2;
}
//Default constructer
Pokemon::Pokemon() {
name = "Pichario";
type = "Death";
weight = 10;
height = 12;
Gender = "Male and Female";
evoLevel = 1;
finalEvo = true;
dexNum = 999;
}
main.cpp:
#include <iostream>
#include <string>
#include <vector>
#include "Pokemon.h"
int main() {
//Create Pokemon objects
Pokemon bulbasaur("Bulbasaur", "Grass and Poison", 15.2, 28, "Male and Female", 1, false, 1);
Pokemon ivysaur("Ivysaur", "Grass and Poison", 28.7, 39, "Male and Female", 2, false, 2);
Pokemon venusaur("Venusaur", "Grass and Poison", 220.5, 79, "Male and Female", 3, true, 3);
Pokemon charmander("Charmander", "Fire", 18.7, 24, "Male and Female", 1, false, 4);
Pokemon charmeleon("Charmeleon", "Fire", 41.9, 44, "Male and Female", 2, false, 5);
Pokemon charizard("Charizard", "Fire and Flying", 199.5, 67, "Male and Female", 3, true, 6);
Pokemon squirtle("Squirtle", "Water", 19.8, 20, "Male and Female", 1, false, 7);
Pokemon wartortle("Wartortle", "Water", 49.6, 39, "Male and Female", 2, false, 8);
Pokemon blastoise("Blastoise", "Water", 188.5, 63, "Male and Female", 3, true, 9);
Pokemon caterpie("Caterpie", "Bug", 6.4, 12, "Male and Female", 1, false, 10);
Pokemon metapod("Metapod", "Bug", 21.8, 28, "Male and Female", 2, false, 11);
Pokemon butterfree("Butterfree", "Bug and Flying", 70.5, 43, "Male and Female", 3, true, 12);
Pokemon weedle("Weedle", "Bug and Poison", 7.1, 12, "Male and Female", 1, false, 13);
Pokemon kakuna("Kakuna", "Bug and Poison", 22, 24, "Male and Female", 2, false, 14);
Pokemon beedrill("Beedrill", "Bug and Poison", 65, 39, "Male and Female", 3, true, 15);
Pokemon pidgey("Pidgey", "Normal and Flying", 4, 12, "Male and Female", 1, false, 16);
Pokemon pidgeotto("Pidgeotto", "Normal and Flying", 66.1, 43, "Male and Female", 2, false, 17);
Pokemon pidgeot("Pidgeot", "Normal and Flying", 87.1, 59, "Male and Female", 3, true, 18);
Pokemon rattata("Rattata", "Normal", 7.7, 12, "Male and Female", 1, false, 19);
Pokemon raticate("Raticate", "Normal", 40.8, 28, "Male and Female", 2, true, 20);