From dd4f9ada0e5fb6f261753838b0053dbdbf2fbde9 Mon Sep 17 00:00:00 2001 From: rangamach <117797904+rangamach@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:50:18 +0530 Subject: [PATCH 1/5] Enter Name --- Pokemon/Pokemon/Pokemon.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Pokemon/Pokemon/Pokemon.cpp b/Pokemon/Pokemon/Pokemon.cpp index 70d0cba..b484d92 100644 --- a/Pokemon/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon/Pokemon.cpp @@ -1,20 +1,11 @@ -// Pokemon.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - #include +using namespace std; + int main() { - std::cout << "Hello World!\n"; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file + string player_name; + cout << "Enter your Name: "; + cin >> player_name; + cout << "Welcone to world of Pokemon " + player_name + "!"; +} \ No newline at end of file From c05b631be78eff1295080d895faad2a0e43c2cb8 Mon Sep 17 00:00:00 2001 From: rangamach <117797904+rangamach@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:16:20 +0530 Subject: [PATCH 2/5] Choose First Pokemon --- Pokemon/Pokemon/Pokemon.cpp | 55 ++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/Pokemon/Pokemon/Pokemon.cpp b/Pokemon/Pokemon/Pokemon.cpp index b484d92..51dfb85 100644 --- a/Pokemon/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon/Pokemon.cpp @@ -2,10 +2,57 @@ using namespace std; -int main() +static string EnterName() { - string player_name; + string name; cout << "Enter your Name: "; - cin >> player_name; - cout << "Welcone to world of Pokemon " + player_name + "!"; + cin >> name; + return name; +} + +static void WelcomeMessage(string name) +{ + cout << "Welcome " + name + "!\n"; +} + +static void ChooseFirstPokemon() +{ + cout << "Welcome to the world of Pokemon! I am Professor Oak.\n"; + cout << "You can choose one of the following Pokemon:\n"; + cout << "1. Bulbasaur\n2. Charmander\n3. Squirtle\n"; + cout << "Which Pokemon would you like to choose? Enter the number: "; + + int choice; + cin >> choice; + + switch (choice) + { + case 1: + cout << "You chose Bulbasaur! A wise choice.\n"; + break; + case 2: + cout << "You chose Charmander! A fiery choice.\n"; + break; + case 3: + cout << "You chose Squirtle! A cool choice.\n"; + break; + default: + cout << "Invalid choice. Please restart the game.\n"; + break; + } + + cout << "Ah, an excellent choice!\n"; + cout << "But beware, Trainer,\n"; + cout << "this is only the beginning.\n"; + cout << "Your journey is about to unfold.\n"; + cout << "Now let's see if you've got what it takes to keep going!\n"; + cout << "Good luck, and remember. . . Choose Wisely!\n"; +} + + + +int main() +{ + WelcomeMessage(EnterName()); + ChooseFirstPokemon(); } \ No newline at end of file From 6c2b609fc6fdb8ffec0f8fd33263958b491c37fe Mon Sep 17 00:00:00 2001 From: rangamach <117797904+rangamach@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:13:52 +0530 Subject: [PATCH 3/5] Professor Oak Dialogue --- Pokemon/Pokemon/Pokemon.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Pokemon/Pokemon/Pokemon.cpp b/Pokemon/Pokemon/Pokemon.cpp index 51dfb85..45d2791 100644 --- a/Pokemon/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon/Pokemon.cpp @@ -2,6 +2,8 @@ using namespace std; +string player_name; + static string EnterName() { string name; @@ -22,30 +24,40 @@ static void ChooseFirstPokemon() cout << "1. Bulbasaur\n2. Charmander\n3. Squirtle\n"; cout << "Which Pokemon would you like to choose? Enter the number: "; + string chosen_pokemon; int choice; cin >> choice; switch (choice) { case 1: + chosen_pokemon = "Bulbasaur"; cout << "You chose Bulbasaur! A wise choice.\n"; break; case 2: + chosen_pokemon = "Charmander"; cout << "You chose Charmander! A fiery choice.\n"; break; case 3: + chosen_pokemon = "Squirtle"; cout << "You chose Squirtle! A cool choice.\n"; break; default: - cout << "Invalid choice. Please restart the game.\n"; + cout << "Professor Oak: Hmm, that doesn't seem right. Let me choose for you...\n"; + chosen_pokemon = "Pikachu"; + cout << "Professor Oak: Just kidding! Let's go with Pikachu, the surprise guest!\n"; break; } cout << "Ah, an excellent choice!\n"; + cout << "Professor Oak: " << chosen_pokemon << " and you, " + << player_name << ", are going to be the best of friends!\n"; cout << "But beware, Trainer,\n"; cout << "this is only the beginning.\n"; cout << "Your journey is about to unfold.\n"; cout << "Now let's see if you've got what it takes to keep going!\n"; + cout << "Professor Oak: Your journey begins now!"; + cout << "Get ready to explore the vast world of Pokemon!\n"; cout << "Good luck, and remember. . . Choose Wisely!\n"; } @@ -53,6 +65,7 @@ static void ChooseFirstPokemon() int main() { - WelcomeMessage(EnterName()); + player_name = EnterName(); + WelcomeMessage(player_name); ChooseFirstPokemon(); } \ No newline at end of file From 427f70cd650cd6f5f8d32bc7ae0f15988d8cdacc Mon Sep 17 00:00:00 2001 From: rangamach <117797904+rangamach@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:22:29 +0530 Subject: [PATCH 4/5] Optimized Choosing of Pokemon --- Pokemon/Pokemon/Pokemon.cpp | 43 ++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/Pokemon/Pokemon/Pokemon.cpp b/Pokemon/Pokemon/Pokemon.cpp index 45d2791..ebe25d8 100644 --- a/Pokemon/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon/Pokemon.cpp @@ -4,6 +4,15 @@ using namespace std; string player_name; +enum Pokemon_Choice +{ + Charmander, + Bulbasaur, + Squirtle, + Chosen_For_You +}; + +Pokemon_Choice chosen_pokemon; static string EnterName() { string name; @@ -24,34 +33,47 @@ static void ChooseFirstPokemon() cout << "1. Bulbasaur\n2. Charmander\n3. Squirtle\n"; cout << "Which Pokemon would you like to choose? Enter the number: "; - string chosen_pokemon; int choice; cin >> choice; switch (choice) { case 1: - chosen_pokemon = "Bulbasaur"; - cout << "You chose Bulbasaur! A wise choice.\n"; + chosen_pokemon = Charmander; break; case 2: - chosen_pokemon = "Charmander"; - cout << "You chose Charmander! A fiery choice.\n"; + chosen_pokemon = Bulbasaur; + break; case 3: - chosen_pokemon = "Squirtle"; + chosen_pokemon = Squirtle; + + break; + default: + chosen_pokemon = Chosen_For_You; + break; + } + + switch (chosen_pokemon) + { + case Charmander: + cout << "You chose Bulbasaur! A wise choice.\n"; + break; + case Bulbasaur: + cout << "You chose Charmander! A fiery choice.\n"; + break; + case Squirtle: cout << "You chose Squirtle! A cool choice.\n"; break; default: cout << "Professor Oak: Hmm, that doesn't seem right. Let me choose for you...\n"; - chosen_pokemon = "Pikachu"; - cout << "Professor Oak: Just kidding! Let's go with Pikachu, the surprise guest!\n"; + chosen_pokemon = Charmander; + cout << "Professor Oak: Just kidding! Let's go with Charmander, the surprise guest!\n"; break; } cout << "Ah, an excellent choice!\n"; - cout << "Professor Oak: " << chosen_pokemon << " and you, " - << player_name << ", are going to be the best of friends!\n"; + cout << "Professor Oak: " << (chosen_pokemon == Charmander ? "Charmander" : chosen_pokemon == Bulbasaur ? "Bulbasaur" : "Squirtle") << " and you, " << player_name << ", are going to be the best of friends!\n"; cout << "But beware, Trainer,\n"; cout << "this is only the beginning.\n"; cout << "Your journey is about to unfold.\n"; @@ -66,6 +88,7 @@ static void ChooseFirstPokemon() int main() { player_name = EnterName(); + chosen_pokemon = Chosen_For_You; WelcomeMessage(player_name); ChooseFirstPokemon(); } \ No newline at end of file From 1fdc2c41a1228b8c22ae4a29d7ce6e4687d0d6f4 Mon Sep 17 00:00:00 2001 From: rangamach <117797904+rangamach@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:01:01 +0530 Subject: [PATCH 5/5] Changed enum to enum classes --- Pokemon/Pokemon/Pokemon.cpp | 69 +++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/Pokemon/Pokemon/Pokemon.cpp b/Pokemon/Pokemon/Pokemon.cpp index ebe25d8..d98f678 100644 --- a/Pokemon/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon/Pokemon.cpp @@ -1,10 +1,10 @@ #include +#include using namespace std; -string player_name; - -enum Pokemon_Choice +//Enum Classes +enum class Pokemon_Choice { Charmander, Bulbasaur, @@ -12,7 +12,34 @@ enum Pokemon_Choice Chosen_For_You }; -Pokemon_Choice chosen_pokemon; +enum class Pokemon_Types +{ + Normal_Type, + Fire_Type, + Water_Type, + Electric_Type, + Grass_Type, + Ice_Type, + Fighting_Type, + Poison_Type, + Ground_Type, + Flying_Type, + Psychic_Type, + Bug_Type, + Rock_Type, + Ghost_Type, + Dragon_Type, + Dark_Type, + Steel_Type, + Fairy_Type +}; + + +//Variables +string player_name; +vector captured_pokemon; + +//Functions static string EnterName() { string name; @@ -26,8 +53,9 @@ static void WelcomeMessage(string name) cout << "Welcome " + name + "!\n"; } -static void ChooseFirstPokemon() +Pokemon_Choice ChooseFirstPokemon() { + Pokemon_Choice chosen_pokemon; cout << "Welcome to the world of Pokemon! I am Professor Oak.\n"; cout << "You can choose one of the following Pokemon:\n"; cout << "1. Bulbasaur\n2. Charmander\n3. Squirtle\n"; @@ -39,41 +67,39 @@ static void ChooseFirstPokemon() switch (choice) { case 1: - chosen_pokemon = Charmander; + chosen_pokemon = Pokemon_Choice::Charmander; break; case 2: - chosen_pokemon = Bulbasaur; - + chosen_pokemon = Pokemon_Choice::Bulbasaur; break; case 3: - chosen_pokemon = Squirtle; - + chosen_pokemon = Pokemon_Choice::Squirtle; break; default: - chosen_pokemon = Chosen_For_You; + chosen_pokemon = Pokemon_Choice::Chosen_For_You; break; } switch (chosen_pokemon) { - case Charmander: - cout << "You chose Bulbasaur! A wise choice.\n"; - break; - case Bulbasaur: + case Pokemon_Choice::Charmander: cout << "You chose Charmander! A fiery choice.\n"; break; - case Squirtle: + case Pokemon_Choice::Bulbasaur: + cout << "You chose Bulbasaur! A wise choice.\n"; + break; + case Pokemon_Choice::Squirtle: cout << "You chose Squirtle! A cool choice.\n"; break; default: cout << "Professor Oak: Hmm, that doesn't seem right. Let me choose for you...\n"; - chosen_pokemon = Charmander; + chosen_pokemon = Pokemon_Choice::Charmander; cout << "Professor Oak: Just kidding! Let's go with Charmander, the surprise guest!\n"; break; } cout << "Ah, an excellent choice!\n"; - cout << "Professor Oak: " << (chosen_pokemon == Charmander ? "Charmander" : chosen_pokemon == Bulbasaur ? "Bulbasaur" : "Squirtle") << " and you, " << player_name << ", are going to be the best of friends!\n"; + cout << "Professor Oak: " << (chosen_pokemon == Pokemon_Choice::Charmander ? "Charmander" : chosen_pokemon == Pokemon_Choice::Bulbasaur ? "Bulbasaur" : "Squirtle") << " and you, " << player_name << ", are going to be the best of friends!\n"; cout << "But beware, Trainer,\n"; cout << "this is only the beginning.\n"; cout << "Your journey is about to unfold.\n"; @@ -81,14 +107,13 @@ static void ChooseFirstPokemon() cout << "Professor Oak: Your journey begins now!"; cout << "Get ready to explore the vast world of Pokemon!\n"; cout << "Good luck, and remember. . . Choose Wisely!\n"; -} - + return chosen_pokemon; +} int main() { player_name = EnterName(); - chosen_pokemon = Chosen_For_You; WelcomeMessage(player_name); - ChooseFirstPokemon(); + captured_pokemon.push_back(ChooseFirstPokemon()); } \ No newline at end of file