In: Computer Science
Write a method that takes four strings as parameter. The first string should be a pokemon name, the second a pokemon type, the third a pokemon name, and the fourth a pokemon type. The method should print out which pokemon has the advantage over the other based on their type. In this case you can use fire, water, and leaf. Example outputs should be like:
Example:
Pokemon X (Water) has the advantage over Pokemon Y (fire)
Pokemon X (Fire) has the advantage over Pokemon Y (leaf)
Pokemon X (Leaf) has the advantage over Pokemon Y (water)
#include<bits/stdc++.h>
using namespace std;
void pokemon(string p1, string t1, string p2, string t2) {
if (t1 == "water" && t2 == "fire") {
cout << "Pokemon " << p1 << " (" << t1 << ")" << " has the advantage over Pokemon " << p2 << " (" << t2 << ")\n";
} else if (t2 == "water" && t2 == "fire") {
cout << "Pokemon " << p2 << " (" << t2 << ")" << " has the advantage over Pokemon " << p1 << " (" << t1 << ")\n";
}else if (t1 == "fire" && t2 == "leaf") {
cout << "Pokemon " << p1 << " (" << t1 << ")" << " has the advantage over Pokemon " << p2 << " (" << t2 << ")\n";
} else if (t2 == "fire" && t2 == "leaf") {
cout << "Pokemon " << p2 << " (" << t2 << ")" << " has the advantage over Pokemon " << p1 << " (" << t1 << ")\n";
}else if (t1 == "leaf" && t2 == "water") {
cout << "Pokemon " << p1 << " (" << t1 << ")" << " has the advantage over Pokemon " << p2 << " (" << t2 << ")\n";
} else if (t2 == "leaf" && t2 == "water") {
cout << "Pokemon " << p2 << " (" << t2 << ")" << " has the advantage over Pokemon " << p1 << " (" << t1 << ")\n";
}
}
int main()
{
pokemon("X","fire","Y","leaf");
}
OUTPUT: