Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- using namespace std;
- class Pokemon
- {
- private:
- string name, type;
- int hp;
- public:
- Pokemon();
- Pokemon(string name);
- Pokemon(string name, string type);
- Pokemon(string name, int hp);
- Pokemon(string name, string type, int hp);
- string toString();
- };
- Pokemon::Pokemon()
- {
- name = "Pikachu";
- type = "Electric";
- hp = 60;
- }
- Pokemon::Pokemon(string name)
- {
- this->name = name;
- type = "Water";
- hp = 60;
- }
- Pokemon::Pokemon(string name, string type)
- {
- this->name = name;
- this->type = type;
- hp = 60;
- }
- Pokemon::Pokemon(string name, int hp)
- {
- this->name = name;
- type = "Grass";
- this->hp = hp;
- }
- Pokemon::Pokemon(string name, string type, int hp)
- {
- this->name = name;
- this->type = type;
- this->hp = hp;
- }
- string Pokemon::toString()
- {
- stringstream ss;
- ss << "Name: " << name << " --> Type: " << type << " --> HP: " << hp;
- return ss.str();
- }
- int main()
- {
- Pokemon myPokemon1;
- Pokemon myPokemon2("Buizel");
- Pokemon myPokemon3("Treecko", "Grass");
- Pokemon myPokemon4("Serperior", 120);
- Pokemon myPokemon5("Dragonite", "Dragon", 150);
- Pokemon myPokemon6("Latios", "Dragon", 130);
- cout << myPokemon1.toString() << endl;
- cout << myPokemon2.toString() << endl;
- cout << myPokemon3.toString() << endl;
- cout << myPokemon4.toString() << endl;
- cout << myPokemon5.toString() << endl;
- cout << myPokemon6.toString() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment