From f9310914a5efd2275efd785161c12b3387922f1f Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Wed, 9 Jul 2025 10:48:38 +0530 Subject: [PATCH 01/18] Added greeting message and name input to main() --- Pokemon/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index c2bc7bfc..6a01d1af 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,6 +1,17 @@ #include +using namespace std; int main() { + string player_name; + cout<< "Enter your Name" << endl; + + cin >> player_name; + + cout << "Great Start " << player_name << ", looks like you have understood the main() function properly now!" << endl; return 0; } + + + + From cd8736172a155841e7e648c1c81bda222136c1ec Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Wed, 9 Jul 2025 12:51:26 +0530 Subject: [PATCH 02/18] Giving the choice to with adding their name --- Pokemon/main.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 6a01d1af..ddf4909f 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -7,7 +7,27 @@ int main() { cin >> player_name; - cout << "Great Start " << player_name << ", looks like you have understood the main() function properly now!" << endl; + cout <<"Welcome to the Pokemon world " << player_name << "!,I am Professor Oak \n"; + cout << "Choose your Pokemon\n"; + cout << "1.Bulbasaur\n2.Charmander\n3.Squirtle\n"; + + int choice; + cin >> choice; + + if (choice == 1) { + cout << "your mate is Bulbasaur\n"; + } + else if (choice == 2) { + cout << "your mate is Charmander\n"; + } + else if (choice == 3) { + cout << "Your mate is Squirtle\n"; + } + else { + cout << "It's an invalid choice\n"; + } + + cout << "Ah, an excellent choice!\nBut beware, Trainer,this is only the beginning.\nYour journey is about to unfold.\nNow let’s see if you’ve got what it takes to keep going!\nGood luck, and remember… Choose wisely!"; return 0; } From 479c3a8b15e79e867442b0accae12a58d90d5c4a Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Fri, 18 Jul 2025 12:37:30 +0530 Subject: [PATCH 03/18] Enum done --- Pokemon/main.cpp | 223 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 202 insertions(+), 21 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index ddf4909f..32af6d8a 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,37 +1,218 @@ #include +#include using namespace std; -int main() { - string player_name; - cout<< "Enter your Name" << endl; - - cin >> player_name; +// Define an enum for Pokemon choices +enum class PokemonChoice { + Charmander = 1, + Bulbasaur, + Squirtle, + InvalidChoice +}; - cout <<"Welcome to the Pokemon world " << player_name << "!,I am Professor Oak \n"; - cout << "Choose your Pokemon\n"; - cout << "1.Bulbasaur\n2.Charmander\n3.Squirtle\n"; +enum class PokemonType { + Fire, + Electric, + Water, + Earth, + Normal +}; - int choice; - cin >> choice; +enum class HealingItems { + Potion, + Elixir +}; + +enum class BattleItems { + Potion, + Elixir +}; + +class Pokemon { +public: + string name; + PokemonType type; + int health; + + //created 2 constructors + Pokemon(){ - if (choice == 1) { - cout << "your mate is Bulbasaur\n"; } - else if (choice == 2) { - cout << "your mate is Charmander\n"; + + Pokemon(string p_name, PokemonType p_type, int p_health) { + name = p_name; + type = p_type; + health = p_health; } - else if (choice == 3) { - cout << "Your mate is Squirtle\n"; + + void attack() { cout << name << " attack with a powerful move!\n"; } +}; + +class Player { +public: + //Attributes + string name; + Pokemon chosenPokemon; + + //Method to choose pokemon + void choosePokemon(int choice) { + switch ((PokemonChoice)choice) { + case PokemonChoice::Charmander: + chosenPokemon = Pokemon("Charmander", PokemonType::Fire, 100); + break; + case PokemonChoice::Bulbasaur: + chosenPokemon = Pokemon("Bulbasaur", PokemonType::Earth, 100); + break; + case PokemonChoice::Squirtle: + chosenPokemon = Pokemon("Squirtle", PokemonType::Water, 100); + break; + default: + chosenPokemon = Pokemon("Pikachu", PokemonType::Electric, 100); + break; + } + cout << "Player " << name << " chose" << chosenPokemon.name << "!\n"; + } - else { - cout << "It's an invalid choice\n"; +}; + +//Professor oak class definition +class ProfessorOak { +public: + string name; + + //method to greet player + void greetPlayer(Player& player) { + cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; + cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; + cout << name << ": But enough about me. Let's talk about you!\n"; } - cout << "Ah, an excellent choice!\nBut beware, Trainer,this is only the beginning.\nYour journey is about to unfold.\nNow let’s see if you’ve got what it takes to keep going!\nGood luck, and remember… Choose wisely!"; + //Method to ask the player to choose a pokemon + void offerPokemonChoices(Player& player) { + cout << name << ": First, tell me, what’s your name?\n"; + getline(cin, player.name); + cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; + cout << name << ": You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; - return 0; -} + //Presenting Pokemon choices + cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; + cout << name << ": Choose wisely...\n"; std::cout << "1. Charmander - The fire type. A real hothead!\n"; + cout << "2. Bulbasaur - The grass type. Calm and collected!\n"; + cout << "3. Squirtle - The water type. Cool as a cucumber!\n"; + + int choice; + cout << name << ": So,which one will it be?Enter the number of your choice\n"; + cin >> choice; + player.choosePokemon(choice); + } +}; + +int main() { + + //Creating Obejcts of ProffessorOak,Pokemon and player class + ProfessorOak professor; + Pokemon placeholderPokemon; + Player player; + //Assigning values to PlaceholderPokemon attributes + placeholderPokemon.name = "Pikachu"; + placeholderPokemon.type = PokemonType::Electric; + placeholderPokemon.health = 40; + //Assigniong values to the player attribute + player.name = "Trainer"; + //Assigning values to the professorOak + professor.name = "Professor Oak"; + //Greet the player and offer Pokemon choices + professor.greetPlayer(player); + professor.offerPokemonChoices(player); + + //Conclude the first chapter + cout << "Professor Oak: " << player.chosenPokemon.name << " and you, " << player.name << ", are going to be the best of friends!\n"; + cout << "Professor Oak: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; + + + /*// Variables to store player name and chosen Pokemon + string player_name; + PokemonChoice chosen_pokemon = PokemonChoice::Charmander; // Default to an invalid choice + */ + //Using HealingItems + /*HealingItems HealPack = HealingItems::Elixir; + + //Using BattleItems + BattleItems BattlePack = BattleItems::Potion; + + cout << "Choose the Pack" << endl; + + switch (HealingItems) { + case 1: cout << "Healing Potion used! Your Pokémon recovers HP!\n"; + break; + case 2: cout << "Healing Elixir used! Your Pokémon recovers HP!\n"; + }*/ + /* + // Introduction by the Professor + cout << "Professor Oak: Hello there! Welcome to the world of Pokemon!\n"; + cout << "Professor Oak: My name is Oak. People call me the Pokemon Professor!\n"; + cout << "Professor Oak: But enough about me. Let's talk about you!\n"; + + // Taking player name as input + cout << "Professor Oak: First, tell me, what’s your name?\n"; + cin >> player_name; + + cout << "Professor Oak: Ah, " << player_name << "! What a fantastic name!\n"; + cout << "Professor Oak: You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; + + // Presenting Pokemon choices + cout << "Professor Oak: I have three Pokemon here with me. They’re all quite feisty!\n"; + cout << "Professor Oak: Choose wisely...\n"; + cout << "1. Charmander - The fire type. A real hothead!\n"; + cout << "2. Bulbasaur - The grass type. Calm and collected!\n"; + cout << "3. Squirtle - The water type. Cool as a cucumber!\n"; + + int choice; + cout << "Professor Oak: So, which one will it be? Enter the number of your choice: "; + cin >> choice; + + // Map the integer choice to the corresponding enum value + switch (choice) { + case 1: + chosen_pokemon = Charmander; + break; + case 2: + chosen_pokemon = Bulbasaur; + break; + case 3: + chosen_pokemon = Squirtle; + break; + default: + chosen_pokemon = InvalidChoice; + break; + } + + // Respond based on the chosen Pokemon + switch (chosen_pokemon) { + case Charmander: + cout << "Professor Oak: A fiery choice! Charmander is yours!\n"; + break; + case Bulbasaur: + cout << "Professor Oak: A fine choice! Bulbasaur is always ready to grow on you!\n"; + break; + case Squirtle: + cout << "Professor Oak: Splendid! Squirtle will keep you cool under pressure!\n"; + break; + default: + cout << "Professor Oak: Hmm, that doesn't seem right. Let me choose for you...\n"; + chosen_pokemon = Charmander; // Default to Charmander if invalid choice + cout << "Professor Oak: Just kidding! Let's go with Charmander, the fiery dragon in the making!\n"; + break; + } + + // Concluding the first chapter + 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: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; + */ + return 0; +} \ No newline at end of file From de466fa5dcd9661189ba024e665791182fe7efc6 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Fri, 18 Jul 2025 17:51:04 +0530 Subject: [PATCH 04/18] Function calls are done! --- Pokemon/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 32af6d8a..97b2988d 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -107,6 +107,20 @@ class ProfessorOak { } }; +void castSpell(int MagicLevel) { + cout << "Casting spell with magic level: "< Date: Mon, 21 Jul 2025 15:53:07 +0530 Subject: [PATCH 05/18] Cmstructor scroll done --- Pokemon/main.cpp | 264 +++++++++++++++++++---------------------------- 1 file changed, 109 insertions(+), 155 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 97b2988d..c4b24bd7 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -4,230 +4,184 @@ using namespace std; // Define an enum for Pokemon choices enum class PokemonChoice { - Charmander = 1, - Bulbasaur, - Squirtle, - InvalidChoice + CHARMANDER = 1, + BULBASAUR, + SQUIRTLE, + PIKACHU // Default choice }; +// Define an enum for Pokemon types enum class PokemonType { - Fire, - Electric, - Water, - Earth, - Normal -}; - -enum class HealingItems { - Potion, - Elixir -}; - -enum class BattleItems { - Potion, - Elixir + FIRE, + GRASS, + WATER, + ELECTRIC, + NORMAL // Added for the default constructor }; +// Pokemon class definition class Pokemon { public: + // Attributes string name; PokemonType type; int health; - //created 2 constructors - Pokemon(){ - + // Default constructor + Pokemon() { + name = "Unknown"; + type = PokemonType::NORMAL; + health = 50; + cout << "A new Pokemon has been created with the default constructor!\n"; } + // Parameterized constructor Pokemon(string p_name, PokemonType p_type, int p_health) { name = p_name; type = p_type; health = p_health; + cout << "A new Pokemon named " << name << " has been created!\n"; + } + + // Copy constructor + Pokemon(const Pokemon& other) { + name = other.name; + type = other.type; + health = other.health; + cout << "A new Pokemon has been copied from " << other.name << "!\n"; + } + + // Destructor + ~Pokemon() { + cout << name << " has been released.\n"; } - void attack() { cout << name << " attack with a powerful move!\n"; } + // Method to simulate attacking (just for demonstration) + void attack() { + cout << name << " attacks with a powerful move!\n"; + } }; +// Player class definition class Player { public: - //Attributes + // Attributes string name; Pokemon chosenPokemon; - //Method to choose pokemon + // Default constructor + Player() { + name = "Trainer"; + chosenPokemon = Pokemon(); // Using the default Pokemon constructor + cout << "A new player named " << name << " has been created!\n"; + } + + // Parameterized constructor + Player(std::string p_name, Pokemon p_chosenPokemon) { + name = p_name; + chosenPokemon = p_chosenPokemon; + cout << "Player " << name << " has been created!\n"; + } + + // Method to choose a Pokemon void choosePokemon(int choice) { switch ((PokemonChoice)choice) { - case PokemonChoice::Charmander: - chosenPokemon = Pokemon("Charmander", PokemonType::Fire, 100); + + case PokemonChoice::CHARMANDER: + chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); break; - case PokemonChoice::Bulbasaur: - chosenPokemon = Pokemon("Bulbasaur", PokemonType::Earth, 100); + case PokemonChoice::BULBASAUR: + chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); break; - case PokemonChoice::Squirtle: - chosenPokemon = Pokemon("Squirtle", PokemonType::Water, 100); + case PokemonChoice::SQUIRTLE: + chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); break; default: - chosenPokemon = Pokemon("Pikachu", PokemonType::Electric, 100); + chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); break; } - cout << "Player " << name << " chose" << chosenPokemon.name << "!\n"; + cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; } }; -//Professor oak class definition +// ProfessorOak class definition class ProfessorOak { public: + // Attributes string name; - //method to greet player + // Parameterized constructor + ProfessorOak(string p_name) { + name = p_name; + } + + // Method to greet the player void greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; cout << name << ": But enough about me. Let's talk about you!\n"; } - //Method to ask the player to choose a pokemon + // Method to ask the player to choose a Pokemon void offerPokemonChoices(Player& player) { cout << name << ": First, tell me, what’s your name?\n"; - getline(cin, player.name); + getline(std::cin, player.name); cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; cout << name << ": You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; - //Presenting Pokemon choices + // Presenting Pokemon choices cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; - cout << name << ": Choose wisely...\n"; std::cout << "1. Charmander - The fire type. A real hothead!\n"; + cout << name << ": Choose wisely...\n"; + cout << "1. Charmander - The fire type. A real hothead!\n"; cout << "2. Bulbasaur - The grass type. Calm and collected!\n"; cout << "3. Squirtle - The water type. Cool as a cucumber!\n"; int choice; - cout << name << ": So,which one will it be?Enter the number of your choice\n"; + cout << name << ": So, which one will it be? Enter the number of your choice: "; cin >> choice; + player.choosePokemon(choice); } }; -void castSpell(int MagicLevel) { - cout << "Casting spell with magic level: "<> player_name; - - cout << "Professor Oak: Ah, " << player_name << "! What a fantastic name!\n"; - cout << "Professor Oak: You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; - - // Presenting Pokemon choices - cout << "Professor Oak: I have three Pokemon here with me. They’re all quite feisty!\n"; - cout << "Professor Oak: Choose wisely...\n"; - cout << "1. Charmander - The fire type. A real hothead!\n"; - cout << "2. Bulbasaur - The grass type. Calm and collected!\n"; - cout << "3. Squirtle - The water type. Cool as a cucumber!\n"; - - int choice; - cout << "Professor Oak: So, which one will it be? Enter the number of your choice: "; - cin >> choice; - - // Map the integer choice to the corresponding enum value - switch (choice) { - case 1: - chosen_pokemon = Charmander; - break; - case 2: - chosen_pokemon = Bulbasaur; - break; - case 3: - chosen_pokemon = Squirtle; - break; - default: - chosen_pokemon = InvalidChoice; - break; - } - - // Respond based on the chosen Pokemon - switch (chosen_pokemon) { - case Charmander: - cout << "Professor Oak: A fiery choice! Charmander is yours!\n"; - break; - case Bulbasaur: - cout << "Professor Oak: A fine choice! Bulbasaur is always ready to grow on you!\n"; - break; - case Squirtle: - cout << "Professor Oak: Splendid! Squirtle will keep you cool under pressure!\n"; - break; - default: - cout << "Professor Oak: Hmm, that doesn't seem right. Let me choose for you...\n"; - chosen_pokemon = Charmander; // Default to Charmander if invalid choice - cout << "Professor Oak: Just kidding! Let's go with Charmander, the fiery dragon in the making!\n"; - break; - } - - // Concluding the first chapter - 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: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; - */ return 0; } \ No newline at end of file From 736cb67979431d28ece8eb72c076158896ff8b73 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Tue, 22 Jul 2025 14:15:20 +0530 Subject: [PATCH 06/18] Main quest done --- Pokemon/main.cpp | 154 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 29 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index c4b24bd7..3e3c9eb3 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -2,6 +2,20 @@ #include using namespace std; +// Function to clear the console +void clearConsole() { + // Platform-specific clear console command +#ifdef _WIN32 + system("cls"); +#else + (void)system("clear"); +#endif +} + +// Function to wait for user to press Enter +void waitForEnter() { + cin.get();//Wait for enter key +} // Define an enum for Pokemon choices enum class PokemonChoice { CHARMANDER = 1, @@ -32,7 +46,6 @@ class Pokemon { name = "Unknown"; type = PokemonType::NORMAL; health = 50; - cout << "A new Pokemon has been created with the default constructor!\n"; } // Parameterized constructor @@ -40,7 +53,6 @@ class Pokemon { name = p_name; type = p_type; health = p_health; - cout << "A new Pokemon named " << name << " has been created!\n"; } // Copy constructor @@ -48,12 +60,11 @@ class Pokemon { name = other.name; type = other.type; health = other.health; - cout << "A new Pokemon has been copied from " << other.name << "!\n"; } // Destructor ~Pokemon() { - cout << name << " has been released.\n"; + //Destructor message removed } // Method to simulate attacking (just for demonstration) @@ -73,14 +84,12 @@ class Player { Player() { name = "Trainer"; chosenPokemon = Pokemon(); // Using the default Pokemon constructor - cout << "A new player named " << name << " has been created!\n"; } // Parameterized constructor Player(std::string p_name, Pokemon p_chosenPokemon) { name = p_name; chosenPokemon = p_chosenPokemon; - cout << "Player " << name << " has been created!\n"; } // Method to choose a Pokemon @@ -119,8 +128,11 @@ class ProfessorOak { // Method to greet the player void greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; + waitForEnter(); cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; + waitForEnter(); cout << name << ": But enough about me. Let's talk about you!\n"; + waitForEnter(); } // Method to ask the player to choose a Pokemon @@ -128,7 +140,9 @@ class ProfessorOak { cout << name << ": First, tell me, what’s your name?\n"; getline(std::cin, player.name); cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; + waitForEnter(); cout << name << ": You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; + waitForEnter(); // Presenting Pokemon choices cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; @@ -143,33 +157,109 @@ class ProfessorOak { player.choosePokemon(choice); } + + void explainMainQuest(Player& player) { + cout << "Professor Oak: Oak-ay" << player.name << "!, I am about to explain you about your upcoming grand adventure.\n"; + waitForEnter(); + cout << "Professor Oak: You see, becoming a Pokémon Master is no easy feat. It takes courage, wisdom, and a bit of luck!\n"; + waitForEnter(); + cout << "Professor Oak: Your mission, should you choose to accept it—and trust me, you really don’t have a choice—is to collect all the Pokémon Badges and conquer the Pokémon League.\n"; + waitForEnter(); + + cout << "\n" << player.name << ": Wait... that sounds a lot like every other Pokémon game out there...\n"; + waitForEnter(); + cout << "Professor Oak: Shhh! Don't break the fourth wall, " << player.name << "! This is serious business!\n"; + waitForEnter(); + + cout << "\nProfessor Oak: To achieve this, you’ll need to battle wild Pokémon, challenge gym leaders, and of course, keep your Pokémon healthy at the PokeCenter.\n"; + waitForEnter(); + cout << "Professor Oak: Along the way, you'll capture new Pokémon to strengthen your team. Just remember—there’s a limit to how many Pokémon you can carry, so choose wisely!\n"; + waitForEnter(); + + cout << "\n" << player.name << ": Sounds like a walk in the park... right?\n"; + waitForEnter(); + cout << "Professor Oak: Hah! That’s what they all say! But beware, young Trainer, the path to victory is fraught with challenges. And if you lose a battle... well, let’s just say you'll be starting from square one.\n"; + waitForEnter(); + + cout << "\nProfessor Oak: So, what do you say? Are you ready to become the next Pokémon Champion?\n"; + waitForEnter(); + cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; + waitForEnter(); + + cout << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; + waitForEnter(); + cout << "Professor Oak: But first... let's just pretend I didn't forget to set up the actual game loop... Ahem, onwards!\n"; + waitForEnter(); + } + + }; -int main() { - // Task 1: Test default and parameterized constructors - Pokemon defaultPokemon; // Using default constructor - Pokemon charmander("Charmander", PokemonType::FIRE, 100); // Using parameterized constructor +//Function to handle the main game loop +void gameloop(Player& player) { + int choice; + bool keepPlaying = true; + + while (keepPlaying) { + //Clear console before showing options + clearConsole(); - cout << "Pokemon Details:\n"; - cout << "Name: " << defaultPokemon.name << "\nType: " << (int)defaultPokemon.type << "\nHealth: " << defaultPokemon.health << "\n"; - cout << "Name: " << charmander.name << "\nType: " << (int)charmander.type << "\nHealth: " << charmander.health << "\n"; + // Display options to the player + cout << "\nWhat would you like to do next, " << player.name << "?\n"; + cout << "1. Battle Wild Pokémon\n"; + cout << "2. Visit PokeCenter\n"; + cout << "3. Challenge Gyms\n"; + cout << "4. Enter Pokémon League\n"; + cout << "5. Quit\n"; + cout << "Enter your choice: "; + cin >> choice; - // Task 2: Test the copy constructor - Pokemon bulbasaur("Bulbasaur", PokemonType::GRASS, 100); // Create a Pokemon - Pokemon bulbasaurCopy = bulbasaur; // Copy the Pokemon - cout << "Original Pokemon Health: " << bulbasaur.health << "\n"; - cout << "Copied Pokemon Health: " << bulbasaurCopy.health << "\n"; + //Clear the newline character left in the buffer after cin >> choice + cin.ignore(numeric_limits::max(), '\n'); - // Modify the copy - bulbasaurCopy.health = 80; - cout << "After Modification:\n"; - cout << "Original Pokemon Health: " << bulbasaur.health << "\n"; - cout << "Copied Pokemon Health: " << bulbasaurCopy.health << "\n"; + // Process the player's choice and display the corresponding message + switch (choice) { + case 1: + cout << "You look around... but all the wild Pokémon are on " + "vacation. Maybe try again later?\n"; + break; + case 2: + cout + << "You head to the PokeCenter, but Nurse Joy is out on a coffee " + "break. Guess your Pokémon will have to tough it out for now!\n"; + break; + case 3: + cout << "You march up to the Gym, but it's closed for renovations. " + "Seems like even Gym Leaders need a break!\n"; + break; + case 4: + cout << "You boldly step towards the Pokémon League... but the " + "gatekeeper laughs and says, 'Maybe next time, champ!'\n"; + break; + case 5: + cout << "You try to quit, but Professor Oak's voice echoes: " + "There is no quitting in Pokemon training!\n"; + cout << "Are you sure you want to quit?(y/n)"; + char quitChoice; + cin >> quitChoice; + if (quitChoice == 'Y' || quitChoice == 'y'){ + keepPlaying = false; + } + break; + default: + cout << "That's not a valid choice.Try again!\n"; + break; + } + // Wait for Enter key before the screen is cleared and the menu is shown + // again + waitForEnter(); + } + cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; +} - // Task 3: Test the destructor - { - Pokemon squirtle("Squirtle", PokemonType::WATER, 100); // Pokemon will be destroyed at the end of this scope - } // Destructor will be called here +int main() { + // Create Pokemon and Player objects for the game + Pokemon charmander("Charmander", PokemonType::FIRE, 100); // Using parameterized constructor // Continue with the main flow of the game ProfessorOak professor("Professor Oak"); @@ -179,9 +269,15 @@ int main() { professor.greetPlayer(player); professor.offerPokemonChoices(player); - // Conclude the first chapter + //Explain the main quest + professor.explainMainQuest(player); + + //Start the main game loop + gameloop(player); + + /*// Conclude the first chapter cout << "Professor Oak: " << player.chosenPokemon.name << " and you, " << player.name << ", are going to be the best of friends!\n"; cout << "Professor Oak: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; - + */ return 0; } \ No newline at end of file From dd1ccfdaec8e24fa8d23bf682a1ef2d68311c02e Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Tue, 29 Jul 2025 00:22:34 +0530 Subject: [PATCH 07/18] head --- Pokemon/header.cpp | 1 + Pokemon/header.h | 6 ++ Pokemon/main.cpp | 159 ++++++++++++++++++++++++++------------------- 3 files changed, 99 insertions(+), 67 deletions(-) create mode 100644 Pokemon/header.cpp create mode 100644 Pokemon/header.h diff --git a/Pokemon/header.cpp b/Pokemon/header.cpp new file mode 100644 index 00000000..f5bec35f --- /dev/null +++ b/Pokemon/header.cpp @@ -0,0 +1 @@ +#include "header.h" diff --git a/Pokemon/header.h b/Pokemon/header.h new file mode 100644 index 00000000..82876bef --- /dev/null +++ b/Pokemon/header.h @@ -0,0 +1,6 @@ +#pragma once +class header +{ + +}; + diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 3e3c9eb3..704e23b8 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,4 +1,5 @@ #include +#include // Include this header to use numeric_limits #include using namespace std; @@ -14,10 +15,11 @@ void clearConsole() { // Function to wait for user to press Enter void waitForEnter() { - cin.get();//Wait for enter key + cin.get(); // Wait for Enter key } + // Define an enum for Pokemon choices -enum class PokemonChoice { +enum PokemonChoice { CHARMANDER = 1, BULBASAUR, SQUIRTLE, @@ -25,7 +27,7 @@ enum class PokemonChoice { }; // Define an enum for Pokemon types -enum class PokemonType { +enum PokemonType { FIRE, GRASS, WATER, @@ -36,7 +38,6 @@ enum class PokemonType { // Pokemon class definition class Pokemon { public: - // Attributes string name; PokemonType type; int health; @@ -44,12 +45,12 @@ class Pokemon { // Default constructor Pokemon() { name = "Unknown"; - type = PokemonType::NORMAL; + type = NORMAL; health = 50; } // Parameterized constructor - Pokemon(string p_name, PokemonType p_type, int p_health) { + Pokemon(std::string p_name, PokemonType p_type, int p_health) { name = p_name; type = p_type; health = p_health; @@ -64,19 +65,15 @@ class Pokemon { // Destructor ~Pokemon() { - //Destructor message removed + // Destructor message removed } - // Method to simulate attacking (just for demonstration) - void attack() { - cout << name << " attacks with a powerful move!\n"; - } + void attack() { std::cout << name << " attacks with a powerful move!\n"; } }; // Player class definition class Player { public: - // Attributes string name; Pokemon chosenPokemon; @@ -92,116 +89,144 @@ class Player { chosenPokemon = p_chosenPokemon; } - // Method to choose a Pokemon void choosePokemon(int choice) { - switch ((PokemonChoice)choice) { - - case PokemonChoice::CHARMANDER: - chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); + switch (choice) { + case CHARMANDER: + chosenPokemon = Pokemon("Charmander", FIRE, 100); break; - case PokemonChoice::BULBASAUR: - chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); + case BULBASAUR: + chosenPokemon = Pokemon("Bulbasaur", GRASS, 100); break; - case PokemonChoice::SQUIRTLE: - chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); + case SQUIRTLE: + chosenPokemon = Pokemon("Squirtle", WATER, 100); break; default: - chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); + chosenPokemon = Pokemon("Pikachu", ELECTRIC, 100); break; } - cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; + waitForEnter(); // Wait for user to press Enter before proceeding } }; // ProfessorOak class definition class ProfessorOak { public: - // Attributes string name; // Parameterized constructor - ProfessorOak(string p_name) { - name = p_name; - } + ProfessorOak(string p_name) { name = p_name; } - // Method to greet the player void greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; waitForEnter(); - cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; + cout << name + << ": My name is Oak. People call me the Pokemon Professor!\n"; waitForEnter(); cout << name << ": But enough about me. Let's talk about you!\n"; waitForEnter(); } - // Method to ask the player to choose a Pokemon void offerPokemonChoices(Player& player) { - cout << name << ": First, tell me, what’s your name?\n"; + cout + << name + << ": First, tell me, what’s your name? \t [Please Enter Your Name]\n"; getline(std::cin, player.name); - cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; + cout << name << ": Ah, " << player.name + << "! What a fantastic name!\n"; waitForEnter(); - cout << name << ": You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; + cout << name + << ": You must be eager to start your adventure. But first, " + "you’ll need a Pokemon of your own!\n"; waitForEnter(); // Presenting Pokemon choices - cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; + cout + << name + << ": I have three Pokemon here with me. They’re all quite feisty!\n"; + waitForEnter(); cout << name << ": Choose wisely...\n"; cout << "1. Charmander - The fire type. A real hothead!\n"; cout << "2. Bulbasaur - The grass type. Calm and collected!\n"; cout << "3. Squirtle - The water type. Cool as a cucumber!\n"; int choice; - cout << name << ": So, which one will it be? Enter the number of your choice: "; + cout + << name + << ": So, which one will it be? Enter the number of your choice: "; cin >> choice; player.choosePokemon(choice); + waitForEnter(); } + // New method for the main quest conversation void explainMainQuest(Player& player) { - cout << "Professor Oak: Oak-ay" << player.name << "!, I am about to explain you about your upcoming grand adventure.\n"; + // Clear the console + clearConsole(); + + cout << "Professor Oak: " << player.name + << "!, I am about to explain you about your upcoming grand " + "adventure.\n"; waitForEnter(); - cout << "Professor Oak: You see, becoming a Pokémon Master is no easy feat. It takes courage, wisdom, and a bit of luck!\n"; + cout << "Professor Oak: You see, becoming a Pokémon Master is no easy " + "feat. It takes courage, wisdom, and a bit of luck!\n"; waitForEnter(); - cout << "Professor Oak: Your mission, should you choose to accept it—and trust me, you really don’t have a choice—is to collect all the Pokémon Badges and conquer the Pokémon League.\n"; + cout + << "Professor Oak: Your mission, should you choose to accept it—and " + "trust me, you really don’t have a choice—is to collect all the " + "Pokémon Badges and conquer the Pokémon League.\n"; waitForEnter(); - cout << "\n" << player.name << ": Wait... that sounds a lot like every other Pokémon game out there...\n"; + cout << "\n" + << player.name + << ": Wait... that sounds a lot like every other Pokémon game " + "out there...\n"; waitForEnter(); - cout << "Professor Oak: Shhh! Don't break the fourth wall, " << player.name << "! This is serious business!\n"; + cout << "Professor Oak: Shhh! Don't break the fourth wall, " + << player.name << "! This is serious business!\n"; waitForEnter(); - cout << "\nProfessor Oak: To achieve this, you’ll need to battle wild Pokémon, challenge gym leaders, and of course, keep your Pokémon healthy at the PokeCenter.\n"; + cout << "\nProfessor Oak: To achieve this, you’ll need to battle wild " + "Pokémon, challenge gym leaders, and of course, keep your " + "Pokémon healthy at the PokeCenter.\n"; waitForEnter(); - cout << "Professor Oak: Along the way, you'll capture new Pokémon to strengthen your team. Just remember—there’s a limit to how many Pokémon you can carry, so choose wisely!\n"; + cout << "Professor Oak: Along the way, you'll capture new Pokémon to " + "strengthen your team. Just remember—there’s a limit to how " + "many Pokémon you can carry, so choose wisely!\n"; waitForEnter(); - cout << "\n" << player.name << ": Sounds like a walk in the park... right?\n"; + cout << "\n" + << player.name << ": Sounds like a walk in the park... right?\n"; waitForEnter(); - cout << "Professor Oak: Hah! That’s what they all say! But beware, young Trainer, the path to victory is fraught with challenges. And if you lose a battle... well, let’s just say you'll be starting from square one.\n"; + cout << "Professor Oak: Hah! That’s what they all say! But beware, " + "young Trainer, the path to victory is fraught with " + "challenges. And if you lose a battle... well, let’s just say " + "you'll be starting from square one.\n"; waitForEnter(); - cout << "\nProfessor Oak: So, what do you say? Are you ready to become the next Pokémon Champion?\n"; + cout << "\nProfessor Oak: So, what do you say? Are you ready to " + "become the next Pokémon Champion?\n"; waitForEnter(); cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; waitForEnter(); - cout << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; + cout + << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; waitForEnter(); - cout << "Professor Oak: But first... let's just pretend I didn't forget to set up the actual game loop... Ahem, onwards!\n"; + cout << "Professor Oak: But first... let's just pretend I didn't " + "forget to set up the actual game loop... Ahem, onwards!\n"; waitForEnter(); } - - }; -//Function to handle the main game loop -void gameloop(Player& player) { +// Function to handle the main game loop +void gameLoop(Player& player) { int choice; bool keepPlaying = true; while (keepPlaying) { - //Clear console before showing options + // Clear console before showing options clearConsole(); // Display options to the player @@ -214,9 +239,10 @@ void gameloop(Player& player) { cout << "Enter your choice: "; cin >> choice; - //Clear the newline character left in the buffer after cin >> choice + // Clear the newline character left in the buffer after cin >> choice cin.ignore(numeric_limits::max(), '\n'); + // Process the player's choice and display the corresponding message switch (choice) { case 1: @@ -238,28 +264,31 @@ void gameloop(Player& player) { break; case 5: cout << "You try to quit, but Professor Oak's voice echoes: " - "There is no quitting in Pokemon training!\n"; - cout << "Are you sure you want to quit?(y/n)"; + "'There's no quitting in Pokémon training!'\n"; + cout << "Are you sure you want to quit? (y/n): "; char quitChoice; cin >> quitChoice; - if (quitChoice == 'Y' || quitChoice == 'y'){ + if (quitChoice == 'y' || quitChoice == 'Y') { keepPlaying = false; } break; default: - cout << "That's not a valid choice.Try again!\n"; + cout << "That's not a valid choice. Try again!\n"; break; - } + } + // Wait for Enter key before the screen is cleared and the menu is shown // again waitForEnter(); } + cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; } int main() { // Create Pokemon and Player objects for the game - Pokemon charmander("Charmander", PokemonType::FIRE, 100); // Using parameterized constructor + Pokemon charmander("Charmander", FIRE, + 100); // Using parameterized constructor // Continue with the main flow of the game ProfessorOak professor("Professor Oak"); @@ -269,15 +298,11 @@ int main() { professor.greetPlayer(player); professor.offerPokemonChoices(player); - //Explain the main quest + // Explain the main quest professor.explainMainQuest(player); - //Start the main game loop - gameloop(player); + // Start the main game loop + gameLoop(player); - /*// Conclude the first chapter - cout << "Professor Oak: " << player.chosenPokemon.name << " and you, " << player.name << ", are going to be the best of friends!\n"; - cout << "Professor Oak: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; - */ return 0; -} \ No newline at end of file +} From 17c437945ff3a84bf9c73766b81762b381f0624c Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Tue, 29 Jul 2025 00:49:20 +0530 Subject: [PATCH 08/18] Can't understand the errord --- Pokemon/PokemonChoice.cpp | 1 + Pokemon/PokemonChoice.h | 7 +++++++ Pokemon/PokemonType.cpp | 1 + Pokemon/PokemonType.h | 8 ++++++++ Pokemon/main.cpp | 22 ++++------------------ 5 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 Pokemon/PokemonChoice.cpp create mode 100644 Pokemon/PokemonChoice.h create mode 100644 Pokemon/PokemonType.cpp create mode 100644 Pokemon/PokemonType.h diff --git a/Pokemon/PokemonChoice.cpp b/Pokemon/PokemonChoice.cpp new file mode 100644 index 00000000..3a124bf6 --- /dev/null +++ b/Pokemon/PokemonChoice.cpp @@ -0,0 +1 @@ +#include "PokemonChoice.h" diff --git a/Pokemon/PokemonChoice.h b/Pokemon/PokemonChoice.h new file mode 100644 index 00000000..5e3d29a4 --- /dev/null +++ b/Pokemon/PokemonChoice.h @@ -0,0 +1,7 @@ +// Define an enum for Pokemon choices +enum class PokemonChoice { + CHARMANDER = 1, + BULBASAUR, + SQUIRTLE, + PIKACHU // Default choice +}; \ No newline at end of file diff --git a/Pokemon/PokemonType.cpp b/Pokemon/PokemonType.cpp new file mode 100644 index 00000000..f5bec35f --- /dev/null +++ b/Pokemon/PokemonType.cpp @@ -0,0 +1 @@ +#include "header.h" diff --git a/Pokemon/PokemonType.h b/Pokemon/PokemonType.h new file mode 100644 index 00000000..f50f9252 --- /dev/null +++ b/Pokemon/PokemonType.h @@ -0,0 +1,8 @@ +// Define an enum for Pokemon types +enum class PokemonType { + FIRE, + GRASS, + WATER, + ELECTRIC, + NORMAL // Added for the default constructor +}; diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 704e23b8..32e771f0 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,6 +1,9 @@ +#include"PokemonType.h" +#include"PokemonChoice.h" #include #include // Include this header to use numeric_limits #include + using namespace std; // Function to clear the console @@ -18,23 +21,6 @@ void waitForEnter() { cin.get(); // Wait for Enter key } -// Define an enum for Pokemon choices -enum PokemonChoice { - CHARMANDER = 1, - BULBASAUR, - SQUIRTLE, - PIKACHU // Default choice -}; - -// Define an enum for Pokemon types -enum PokemonType { - FIRE, - GRASS, - WATER, - ELECTRIC, - NORMAL // Added for the default constructor -}; - // Pokemon class definition class Pokemon { public: @@ -285,7 +271,7 @@ void gameLoop(Player& player) { cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; } -int main() { +int main() {s // Create Pokemon and Player objects for the game Pokemon charmander("Charmander", FIRE, 100); // Using parameterized constructor From b075054f166474c79395278379d8f8a366f9a4a9 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Tue, 29 Jul 2025 18:26:43 +0530 Subject: [PATCH 09/18] assignment done --- Pokemon/main.cpp | 105 +++++++++++++++++++------------------------- Pokemon/utility.cpp | 19 ++++++++ Pokemon/utility.h | 9 ++++ 3 files changed, 72 insertions(+), 61 deletions(-) create mode 100644 Pokemon/utility.cpp create mode 100644 Pokemon/utility.h diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 32e771f0..323ccf25 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,26 +1,11 @@ -#include"PokemonType.h" -#include"PokemonChoice.h" +#include "PokemonChoice.h" +#include "PokemonType.h" +#include "utility.h" #include #include // Include this header to use numeric_limits #include - using namespace std; -// Function to clear the console -void clearConsole() { - // Platform-specific clear console command -#ifdef _WIN32 - system("cls"); -#else - (void)system("clear"); -#endif -} - -// Function to wait for user to press Enter -void waitForEnter() { - cin.get(); // Wait for Enter key -} - // Pokemon class definition class Pokemon { public: @@ -31,12 +16,12 @@ class Pokemon { // Default constructor Pokemon() { name = "Unknown"; - type = NORMAL; + type = PokemonType::NORMAL; health = 50; } // Parameterized constructor - Pokemon(std::string p_name, PokemonType p_type, int p_health) { + Pokemon(string p_name, PokemonType p_type, int p_health) { name = p_name; type = p_type; health = p_health; @@ -54,7 +39,7 @@ class Pokemon { // Destructor message removed } - void attack() { std::cout << name << " attacks with a powerful move!\n"; } + void attack() { cout << name << " attacks with a powerful move!\n"; } }; // Player class definition @@ -70,28 +55,28 @@ class Player { } // Parameterized constructor - Player(std::string p_name, Pokemon p_chosenPokemon) { + Player(string p_name, Pokemon p_chosenPokemon) { name = p_name; chosenPokemon = p_chosenPokemon; } void choosePokemon(int choice) { - switch (choice) { - case CHARMANDER: - chosenPokemon = Pokemon("Charmander", FIRE, 100); + switch ((PokemonChoice)choice) { + case PokemonChoice::CHARMANDER: + chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); break; - case BULBASAUR: - chosenPokemon = Pokemon("Bulbasaur", GRASS, 100); + case PokemonChoice::BULBASAUR: + chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); break; - case SQUIRTLE: - chosenPokemon = Pokemon("Squirtle", WATER, 100); + case PokemonChoice::SQUIRTLE: + chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); break; default: - chosenPokemon = Pokemon("Pikachu", ELECTRIC, 100); + chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); break; } cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; - waitForEnter(); // Wait for user to press Enter before proceeding + utility::waitForEnter(); // Wait for user to press Enter before proceeding } }; @@ -105,32 +90,32 @@ class ProfessorOak { void greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; - waitForEnter(); + utility::waitForEnter(); cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; - waitForEnter(); + utility::waitForEnter(); cout << name << ": But enough about me. Let's talk about you!\n"; - waitForEnter(); + utility::waitForEnter(); } void offerPokemonChoices(Player& player) { cout << name << ": First, tell me, what’s your name? \t [Please Enter Your Name]\n"; - getline(std::cin, player.name); + getline(cin, player.name); cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; - waitForEnter(); + utility::waitForEnter(); cout << name << ": You must be eager to start your adventure. But first, " "you’ll need a Pokemon of your own!\n"; - waitForEnter(); + utility::waitForEnter(); // Presenting Pokemon choices cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; - waitForEnter(); + utility::waitForEnter(); cout << name << ": Choose wisely...\n"; cout << "1. Charmander - The fire type. A real hothead!\n"; cout << "2. Bulbasaur - The grass type. Calm and collected!\n"; @@ -143,66 +128,66 @@ class ProfessorOak { cin >> choice; player.choosePokemon(choice); - waitForEnter(); + utility::waitForEnter(); } // New method for the main quest conversation void explainMainQuest(Player& player) { // Clear the console - clearConsole(); + utility::clearConsole(); cout << "Professor Oak: " << player.name << "!, I am about to explain you about your upcoming grand " "adventure.\n"; - waitForEnter(); + utility::waitForEnter(); cout << "Professor Oak: You see, becoming a Pokémon Master is no easy " "feat. It takes courage, wisdom, and a bit of luck!\n"; - waitForEnter(); + utility::waitForEnter(); cout << "Professor Oak: Your mission, should you choose to accept it—and " "trust me, you really don’t have a choice—is to collect all the " "Pokémon Badges and conquer the Pokémon League.\n"; - waitForEnter(); + utility::waitForEnter(); cout << "\n" << player.name << ": Wait... that sounds a lot like every other Pokémon game " "out there...\n"; - waitForEnter(); + utility::waitForEnter(); cout << "Professor Oak: Shhh! Don't break the fourth wall, " << player.name << "! This is serious business!\n"; - waitForEnter(); + utility::waitForEnter(); cout << "\nProfessor Oak: To achieve this, you’ll need to battle wild " "Pokémon, challenge gym leaders, and of course, keep your " "Pokémon healthy at the PokeCenter.\n"; - waitForEnter(); + utility::waitForEnter(); cout << "Professor Oak: Along the way, you'll capture new Pokémon to " "strengthen your team. Just remember—there’s a limit to how " "many Pokémon you can carry, so choose wisely!\n"; - waitForEnter(); + utility::waitForEnter(); cout << "\n" << player.name << ": Sounds like a walk in the park... right?\n"; - waitForEnter(); + utility::waitForEnter(); cout << "Professor Oak: Hah! That’s what they all say! But beware, " "young Trainer, the path to victory is fraught with " "challenges. And if you lose a battle... well, let’s just say " "you'll be starting from square one.\n"; - waitForEnter(); + utility::waitForEnter(); cout << "\nProfessor Oak: So, what do you say? Are you ready to " "become the next Pokémon Champion?\n"; - waitForEnter(); + utility::waitForEnter(); cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; - waitForEnter(); + utility::waitForEnter(); cout << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; - waitForEnter(); + utility::waitForEnter(); cout << "Professor Oak: But first... let's just pretend I didn't " "forget to set up the actual game loop... Ahem, onwards!\n"; - waitForEnter(); + utility::waitForEnter(); } }; @@ -213,7 +198,7 @@ void gameLoop(Player& player) { while (keepPlaying) { // Clear console before showing options - clearConsole(); + utility::clearConsole(); // Display options to the player cout << "\nWhat would you like to do next, " << player.name << "?\n"; @@ -225,9 +210,7 @@ void gameLoop(Player& player) { cout << "Enter your choice: "; cin >> choice; - // Clear the newline character left in the buffer after cin >> choice - cin.ignore(numeric_limits::max(), '\n'); - + utility::clearInputBuffer(); // Clear the input buffer // Process the player's choice and display the corresponding message switch (choice) { @@ -265,15 +248,15 @@ void gameLoop(Player& player) { // Wait for Enter key before the screen is cleared and the menu is shown // again - waitForEnter(); + utility::waitForEnter(); } cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; } -int main() {s +int main() { // Create Pokemon and Player objects for the game - Pokemon charmander("Charmander", FIRE, + Pokemon charmander("Charmander", PokemonType::FIRE, 100); // Using parameterized constructor // Continue with the main flow of the game @@ -291,4 +274,4 @@ int main() {s gameLoop(player); return 0; -} +} \ No newline at end of file diff --git a/Pokemon/utility.cpp b/Pokemon/utility.cpp new file mode 100644 index 00000000..3ad2a280 --- /dev/null +++ b/Pokemon/utility.cpp @@ -0,0 +1,19 @@ +#include "utility.h" +#include +#include +using namespace std; + +void utility::clearConsole() { +#ifdef _WIN32 + system("cls"); +#else + system("clear"); +#endif +} + +void utility::waitForEnter() { + cin.get(); +} + +void utility::clearInputBuffer(){ +} \ No newline at end of file diff --git a/Pokemon/utility.h b/Pokemon/utility.h new file mode 100644 index 00000000..ca322012 --- /dev/null +++ b/Pokemon/utility.h @@ -0,0 +1,9 @@ +#pragma once +class utility +{ +public : + static void clearConsole(); + static void waitForEnter(); + static void clearInputBuffer(); +}; + From dad1bf509257497115f90a8d43009793e11af98e Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Wed, 30 Jul 2025 23:30:06 +0530 Subject: [PATCH 10/18] Deaking with some errors --- Pokemon/Pokemon.sln | 19 +++++++++++++++++++ Pokemon/Pokemon.vcxproj | 10 ++++++++++ Pokemon/Pokemon.vcxproj.filters | 26 ++++++++++++++++++++++++++ Pokemon/Pokemon.vcxproj.user | 4 ++++ Pokemon/PokemonChoice.cpp | 1 - Pokemon/PokemonType.cpp | 2 +- Pokemon/PokemonType.h | 2 +- Pokemon/main.cpp | 1 + Pokemon/player.cpp | 33 +++++++++++++++++++++++++++++++++ Pokemon/player.h | 17 +++++++++++++++++ 10 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 Pokemon/Pokemon.vcxproj.user create mode 100644 Pokemon/player.cpp create mode 100644 Pokemon/player.h diff --git a/Pokemon/Pokemon.sln b/Pokemon/Pokemon.sln index dea79cff..b117a60a 100644 --- a/Pokemon/Pokemon.sln +++ b/Pokemon/Pokemon.sln @@ -1,7 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36310.24 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Pokemon", "Pokemon.vcxproj", "{872261CB-D6AC-488B-91C5-1B44032596F2}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Header.h", "..\Header.h\Header.h.vcxproj", "{47FEE16B-AAEB-4576-91E7-3C9C5225D963}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -18,5 +23,19 @@ Global {872261CB-D6AC-488B-91C5-1B44032596F2}.Release|Win32.Build.0 = Release|Win32 {872261CB-D6AC-488B-91C5-1B44032596F2}.Release|x64.ActiveCfg = Release|x64 {872261CB-D6AC-488B-91C5-1B44032596F2}.Release|x64.Build.0 = Release|x64 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|Win32.ActiveCfg = Debug|Win32 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|Win32.Build.0 = Debug|Win32 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|x64.ActiveCfg = Debug|x64 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|x64.Build.0 = Debug|x64 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|Win32.ActiveCfg = Release|Win32 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|Win32.Build.0 = Release|Win32 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|x64.ActiveCfg = Release|x64 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AA496C07-30CF-4C3C-ABFF-0573647E3200} EndGlobalSection EndGlobal diff --git a/Pokemon/Pokemon.vcxproj b/Pokemon/Pokemon.vcxproj index 9e6331ef..2f89b0e7 100644 --- a/Pokemon/Pokemon.vcxproj +++ b/Pokemon/Pokemon.vcxproj @@ -154,7 +154,11 @@ + + + + @@ -162,6 +166,12 @@ + + + + + + diff --git a/Pokemon/Pokemon.vcxproj.filters b/Pokemon/Pokemon.vcxproj.filters index 644f8bee..3ffc753b 100644 --- a/Pokemon/Pokemon.vcxproj.filters +++ b/Pokemon/Pokemon.vcxproj.filters @@ -18,5 +18,31 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/Pokemon/Pokemon.vcxproj.user b/Pokemon/Pokemon.vcxproj.user new file mode 100644 index 00000000..88a55094 --- /dev/null +++ b/Pokemon/Pokemon.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Pokemon/PokemonChoice.cpp b/Pokemon/PokemonChoice.cpp index 3a124bf6..e69de29b 100644 --- a/Pokemon/PokemonChoice.cpp +++ b/Pokemon/PokemonChoice.cpp @@ -1 +0,0 @@ -#include "PokemonChoice.h" diff --git a/Pokemon/PokemonType.cpp b/Pokemon/PokemonType.cpp index f5bec35f..8b137891 100644 --- a/Pokemon/PokemonType.cpp +++ b/Pokemon/PokemonType.cpp @@ -1 +1 @@ -#include "header.h" + diff --git a/Pokemon/PokemonType.h b/Pokemon/PokemonType.h index f50f9252..3806a62b 100644 --- a/Pokemon/PokemonType.h +++ b/Pokemon/PokemonType.h @@ -5,4 +5,4 @@ enum class PokemonType { WATER, ELECTRIC, NORMAL // Added for the default constructor -}; +}; \ No newline at end of file diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 323ccf25..c56f4c12 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,6 +1,7 @@ #include "PokemonChoice.h" #include "PokemonType.h" #include "utility.h" +#include "player.h" #include #include // Include this header to use numeric_limits #include diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp new file mode 100644 index 00000000..cfaaadf7 --- /dev/null +++ b/Pokemon/player.cpp @@ -0,0 +1,33 @@ +#include "player.h" +#include + +// Default constructor +player::player() { + name = "Trainer"; + chosenPokemon = Pokemon(); // Using the default Pokemon constructor +} + +// Parameterized constructor +player::player(string p_name, Pokemon p_chosenPokemon) { + name = p_name; + chosenPokemon = p_chosenPokemon; +} + +void player::choosePokemon(int choice) { + switch ((PokemonChoice)choice) { + case PokemonChoice::CHARMANDER: + chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); + break; + case PokemonChoice::BULBASAUR: + chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); + break; + case PokemonChoice::SQUIRTLE: + chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); + break; + default: + chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); + break; + } + cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; + utility::waitForEnter(); // Wait for user to press Enter before proceeding +} \ No newline at end of file diff --git a/Pokemon/player.h b/Pokemon/player.h new file mode 100644 index 00000000..98562a80 --- /dev/null +++ b/Pokemon/player.h @@ -0,0 +1,17 @@ +#include +#include"PokemonChoice.h" +#include"PokemonType.h" +#include"utility.h" +using namespace std; +class player +{ +public: + string name; + Pokemon chosenPokemon; + + player();//default constructor + player(string p_name, Pokemon p_chosenPokemon);//Parameterized constructor + + void choosePokemon(int choice);//Method to choose pokemon +}; + From 04b7834da0925603817d9e66c5f7f967649532ee Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 00:26:38 +0530 Subject: [PATCH 11/18] facing errors in player.h and .cpp file --- Pokemon/main.cpp | 39 +-------------------------------------- Pokemon/player.cpp | 13 +++++++------ Pokemon/player.h | 26 +++++++++++++------------- 3 files changed, 21 insertions(+), 57 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index c56f4c12..8b21ed08 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,7 +1,6 @@ #include "PokemonChoice.h" #include "PokemonType.h" #include "utility.h" -#include "player.h" #include #include // Include this header to use numeric_limits #include @@ -43,43 +42,7 @@ class Pokemon { void attack() { cout << name << " attacks with a powerful move!\n"; } }; -// Player class definition -class Player { -public: - string name; - Pokemon chosenPokemon; - - // Default constructor - Player() { - name = "Trainer"; - chosenPokemon = Pokemon(); // Using the default Pokemon constructor - } - - // Parameterized constructor - Player(string p_name, Pokemon p_chosenPokemon) { - name = p_name; - chosenPokemon = p_chosenPokemon; - } - - void choosePokemon(int choice) { - switch ((PokemonChoice)choice) { - case PokemonChoice::CHARMANDER: - chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); - break; - case PokemonChoice::BULBASAUR: - chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); - break; - case PokemonChoice::SQUIRTLE: - chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); - break; - default: - chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); - break; - } - cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; - utility::waitForEnter(); // Wait for user to press Enter before proceeding - } -}; +#include "player.h" // ProfessorOak class definition class ProfessorOak { diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp index cfaaadf7..3da5011b 100644 --- a/Pokemon/player.cpp +++ b/Pokemon/player.cpp @@ -1,19 +1,19 @@ +// Player.cpp #include "player.h" -#include +#include "iostream" +using namespace std; -// Default constructor -player::player() { +Player::Player() { name = "Trainer"; chosenPokemon = Pokemon(); // Using the default Pokemon constructor } -// Parameterized constructor -player::player(string p_name, Pokemon p_chosenPokemon) { +Player::Player(string p_name, Pokemon p_chosenPokemon) { name = p_name; chosenPokemon = p_chosenPokemon; } -void player::choosePokemon(int choice) { +void Player::choosePokemon(int choice) { switch ((PokemonChoice)choice) { case PokemonChoice::CHARMANDER: chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); @@ -25,6 +25,7 @@ void player::choosePokemon(int choice) { chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); break; default: + chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); break; } diff --git a/Pokemon/player.h b/Pokemon/player.h index 98562a80..afb1568c 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,17 +1,17 @@ -#include -#include"PokemonChoice.h" -#include"PokemonType.h" -#include"utility.h" +// Player.h +#include +#include "PokemonType.h" +#include "PokemonChoice.h" +#include "utility.h" using namespace std; -class player -{ -public: - string name; - Pokemon chosenPokemon; - player();//default constructor - player(string p_name, Pokemon p_chosenPokemon);//Parameterized constructor +class Player { +public: + string name; + Pokemon chosenPokemon; - void choosePokemon(int choice);//Method to choose pokemon -}; + Player(); // Default constructor + Player(string p_name, Pokemon p_chosenPokemon); // Parameterized constructor + void choosePokemon(int choice); // Method to choose a Pokemon +}; \ No newline at end of file From 563d1aa1b955a62836622f187f0a7220f789fe80 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 01:08:32 +0530 Subject: [PATCH 12/18] #included --- Pokemon/player.cpp | 3 +++ Pokemon/player.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp index 3da5011b..359662aa 100644 --- a/Pokemon/player.cpp +++ b/Pokemon/player.cpp @@ -1,5 +1,8 @@ // Player.cpp #include "player.h" +#include "PokemonChoice.h" +#include "PokemonType.h" +#include "utility.h" #include "iostream" using namespace std; diff --git a/Pokemon/player.h b/Pokemon/player.h index afb1568c..7b7b7d57 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,8 +1,5 @@ // Player.h #include -#include "PokemonType.h" -#include "PokemonChoice.h" -#include "utility.h" using namespace std; class Player { From 3d8fd92ff8723eb9903a01e337acf460cf673e41 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 02:17:57 +0530 Subject: [PATCH 13/18] Good going --- Pokemon/Pokemon.cpp | 19 +++++++++++++++++++ Pokemon/Pokemon.h | 24 ++++++++++++++++++++++++ Pokemon/main.cpp | 4 ++-- Pokemon/player.h | 1 + 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 Pokemon/Pokemon.cpp create mode 100644 Pokemon/Pokemon.h diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp new file mode 100644 index 00000000..3b2c1b6a --- /dev/null +++ b/Pokemon/Pokemon.cpp @@ -0,0 +1,19 @@ +#include "Pokemon.h" +#include + +Pokemon::Pokemon():name("unknown"),type(PokemonType::NORMAL),health(50){} +// Parameterized constructor +Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health): name(p_name), +type(p_type), +health(p_health) { +} + +// Copy constructor +Pokemon::Pokemon(const Pokemon& other):name(other.name),type(other.type),health(other.health) {} + +// Destructor +Pokemon::~Pokemon() { + // Destructor message removed +} + +void Pokemon::attack() { cout << name << " attacks with a powerful move!\n"; } \ No newline at end of file diff --git a/Pokemon/Pokemon.h b/Pokemon/Pokemon.h new file mode 100644 index 00000000..03e8fef3 --- /dev/null +++ b/Pokemon/Pokemon.h @@ -0,0 +1,24 @@ +#include +#include "PokemonType.h" +using namespace std; + +class Pokemon { +public: + string name; + PokemonType type; + int health; + + // Default constructor + Pokemon(); + + // Parameterized constructor + Pokemon(string p_name, PokemonType p_type, int p_health); + + // Copy constructor + Pokemon(const Pokemon& other); + + // Destructor + ~Pokemon(); + + void attack(); +}; \ No newline at end of file diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 8b21ed08..6d2192c4 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -6,7 +6,7 @@ #include using namespace std; -// Pokemon class definition +/*/ Pokemon class definition class Pokemon { public: string name; @@ -40,7 +40,7 @@ class Pokemon { } void attack() { cout << name << " attacks with a powerful move!\n"; } -}; +};*/ #include "player.h" diff --git a/Pokemon/player.h b/Pokemon/player.h index 7b7b7d57..25fa68f2 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,5 +1,6 @@ // Player.h #include +#include "Pokemon.h" using namespace std; class Player { From 5c143c9fbbd83667a1fd0dc07901c63ff8fe230b Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 02:52:57 +0530 Subject: [PATCH 14/18] Can't understand the error,need help --- Pokemon/Pokemon.cpp | 1 + Pokemon/Pokemon.h | 3 ++- Pokemon/main.cpp | 45 +++++---------------------------------------- Pokemon/player.cpp | 1 + Pokemon/player.h | 3 ++- 5 files changed, 11 insertions(+), 42 deletions(-) diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp index 3b2c1b6a..ba7e8b34 100644 --- a/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon.cpp @@ -1,5 +1,6 @@ #include "Pokemon.h" #include +#include"PokemonType.h" Pokemon::Pokemon():name("unknown"),type(PokemonType::NORMAL),health(50){} // Parameterized constructor diff --git a/Pokemon/Pokemon.h b/Pokemon/Pokemon.h index 03e8fef3..f7f8a549 100644 --- a/Pokemon/Pokemon.h +++ b/Pokemon/Pokemon.h @@ -1,7 +1,8 @@ #include -#include "PokemonType.h" using namespace std; +enum class PokemonType; + class Pokemon { public: string name; diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 6d2192c4..eea74a8d 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,49 +1,14 @@ +class Player; +class Pokemon; +enum PokemonType; #include "PokemonChoice.h" -#include "PokemonType.h" -#include "utility.h" + +#include "Utility.h" #include #include // Include this header to use numeric_limits #include using namespace std; -/*/ Pokemon class definition -class Pokemon { -public: - string name; - PokemonType type; - int health; - - // Default constructor - Pokemon() { - name = "Unknown"; - type = PokemonType::NORMAL; - health = 50; - } - - // Parameterized constructor - Pokemon(string p_name, PokemonType p_type, int p_health) { - name = p_name; - type = p_type; - health = p_health; - } - - // Copy constructor - Pokemon(const Pokemon& other) { - name = other.name; - type = other.type; - health = other.health; - } - - // Destructor - ~Pokemon() { - // Destructor message removed - } - - void attack() { cout << name << " attacks with a powerful move!\n"; } -};*/ - -#include "player.h" - // ProfessorOak class definition class ProfessorOak { public: diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp index 359662aa..4b7c8cdb 100644 --- a/Pokemon/player.cpp +++ b/Pokemon/player.cpp @@ -2,6 +2,7 @@ #include "player.h" #include "PokemonChoice.h" #include "PokemonType.h" +#include "Pokemon.h" #include "utility.h" #include "iostream" using namespace std; diff --git a/Pokemon/player.h b/Pokemon/player.h index 25fa68f2..6a2beb0b 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,8 +1,9 @@ // Player.h #include -#include "Pokemon.h" using namespace std; +class Pokemon; + class Player { public: string name; From 3620d014fb89032e876d9a606ef0b8a4224f9781 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 03:11:12 +0530 Subject: [PATCH 15/18] greetings --- Pokemon/main.cpp | 6 ++---- Pokemon/player.h | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index eea74a8d..d5349b7f 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,13 +1,11 @@ -class Player; -class Pokemon; -enum PokemonType; #include "PokemonChoice.h" - +#include "PokemonType.h" #include "Utility.h" #include #include // Include this header to use numeric_limits #include using namespace std; +#include "player.h" // ProfessorOak class definition class ProfessorOak { diff --git a/Pokemon/player.h b/Pokemon/player.h index 6a2beb0b..eb38a581 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,9 +1,7 @@ // Player.h #include +#include "Pokemon.h" using namespace std; - -class Pokemon; - class Player { public: string name; From d2a4cbf4da058c0476e7fda8bd1faa6ff3e02597 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Fri, 1 Aug 2025 18:08:28 +0530 Subject: [PATCH 16/18] We did it misty! --- Pokemon/Game.cpp | 70 +++++++++++++++++ Pokemon/Game.h | 9 +++ Pokemon/Grass.cpp | 14 ++++ Pokemon/Grass.h | 12 +++ Pokemon/main.cpp | 191 ++-------------------------------------------- 5 files changed, 112 insertions(+), 184 deletions(-) create mode 100644 Pokemon/Game.cpp create mode 100644 Pokemon/Game.h create mode 100644 Pokemon/Grass.cpp create mode 100644 Pokemon/Grass.h diff --git a/Pokemon/Game.cpp b/Pokemon/Game.cpp new file mode 100644 index 00000000..75afc5f8 --- /dev/null +++ b/Pokemon/Game.cpp @@ -0,0 +1,70 @@ +#include "Game.h" +#include "player.h" +#include "utility.h" + +Game::Game() { +} + +// Function to handle the main game loop +void Game::gameLoop(Player& player) { + int choice; + bool keepPlaying = true; + + while (keepPlaying) { + // Clear console before showing options + utility::clearConsole(); + + // Display options to the player + cout << "\nWhat would you like to do next, " << player.name << "?\n"; + cout << "1. Battle Wild Pokémon\n"; + cout << "2. Visit PokeCenter\n"; + cout << "3. Challenge Gyms\n"; + cout << "4. Enter Pokémon League\n"; + cout << "5. Quit\n"; + cout << "Enter your choice: "; + cin >> choice; + + utility::clearInputBuffer(); // Clear the input buffer + + // Process the player's choice and display the corresponding message + switch (choice) { + case 1: + cout << "You look around... but all the wild Pokémon are on " + "vacation. Maybe try again later?\n"; + break; + case 2: + cout + << "You head to the PokeCenter, but Nurse Joy is out on a coffee " + "break. Guess your Pokémon will have to tough it out for now!\n"; + break; + case 3: + cout << "You march up to the Gym, but it's closed for renovations. " + "Seems like even Gym Leaders need a break!\n"; + break; + case 4: + cout << "You boldly step towards the Pokémon League... but the " + "gatekeeper laughs and says, 'Maybe next time, champ!'\n"; + break; + case 5: + cout << "You try to quit, but Professor Oak's voice echoes: " + "'There's no quitting in Pokémon training!'\n"; + cout << "Are you sure you want to quit? (y/n): "; + char quitChoice; + cin >> quitChoice; + if (quitChoice == 'y' || quitChoice == 'Y') { + keepPlaying = false; + } + break; + default: + cout << "That's not a valid choice. Try again!\n"; + break; + } + + // Wait for Enter key before the screen is cleared and the menu is shown + // again + utility::waitForEnter(); + } + + cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; +} + diff --git a/Pokemon/Game.h b/Pokemon/Game.h new file mode 100644 index 00000000..7189ee48 --- /dev/null +++ b/Pokemon/Game.h @@ -0,0 +1,9 @@ +#include +class Game +{ +public: + Game(); + // Function to handle the main game loop + void gameLoop(Player& player); +}; + diff --git a/Pokemon/Grass.cpp b/Pokemon/Grass.cpp new file mode 100644 index 00000000..4ddd09f0 --- /dev/null +++ b/Pokemon/Grass.cpp @@ -0,0 +1,14 @@ +#include "Grass.h" +#include"Pokemon.h" + +Grass forestGrass = { + "Forest", + {{"Pidgey", PokemonType::NORMAL, 40}, {"Caterpie", PokemonType::BUG, 35}}, + 70 +}; + +Grass caveGrass = { + "Cave", + {{"Zubat", PokemonType::POISON, 30}, {"Geodude", PokemonType::ROCK, 50}}, + 80 +}; \ No newline at end of file diff --git a/Pokemon/Grass.h b/Pokemon/Grass.h new file mode 100644 index 00000000..3c0c5c93 --- /dev/null +++ b/Pokemon/Grass.h @@ -0,0 +1,12 @@ +#include +#include +#include"Pokemon.h" +using namespace std; + +struct Grass{ + string environmentType; // Example: "Forest", "Cave", "Riverbank" + vector wildPokemonlist; // List of wild Pokémon that live in this grass + int encounterRate; // Likelihood of encountering a wild Pokémon, out of 100 + +}; + diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index d5349b7f..88776d2a 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,194 +1,16 @@ -#include "PokemonChoice.h" -#include "PokemonType.h" -#include "Utility.h" +#include"Game.h" +#include"player.h" +#include"ProfessorOak.h" #include #include // Include this header to use numeric_limits #include using namespace std; -#include "player.h" - -// ProfessorOak class definition -class ProfessorOak { -public: - string name; - - // Parameterized constructor - ProfessorOak(string p_name) { name = p_name; } - - void greetPlayer(Player& player) { - cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; - utility::waitForEnter(); - cout << name - << ": My name is Oak. People call me the Pokemon Professor!\n"; - utility::waitForEnter(); - cout << name << ": But enough about me. Let's talk about you!\n"; - utility::waitForEnter(); - } - - void offerPokemonChoices(Player& player) { - cout - << name - << ": First, tell me, what’s your name? \t [Please Enter Your Name]\n"; - getline(cin, player.name); - cout << name << ": Ah, " << player.name - << "! What a fantastic name!\n"; - utility::waitForEnter(); - cout << name - << ": You must be eager to start your adventure. But first, " - "you’ll need a Pokemon of your own!\n"; - utility::waitForEnter(); - - // Presenting Pokemon choices - cout - << name - << ": I have three Pokemon here with me. They’re all quite feisty!\n"; - utility::waitForEnter(); - cout << name << ": Choose wisely...\n"; - cout << "1. Charmander - The fire type. A real hothead!\n"; - cout << "2. Bulbasaur - The grass type. Calm and collected!\n"; - cout << "3. Squirtle - The water type. Cool as a cucumber!\n"; - - int choice; - cout - << name - << ": So, which one will it be? Enter the number of your choice: "; - cin >> choice; - - player.choosePokemon(choice); - utility::waitForEnter(); - } - - // New method for the main quest conversation - void explainMainQuest(Player& player) { - // Clear the console - utility::clearConsole(); - - cout << "Professor Oak: " << player.name - << "!, I am about to explain you about your upcoming grand " - "adventure.\n"; - utility::waitForEnter(); - cout << "Professor Oak: You see, becoming a Pokémon Master is no easy " - "feat. It takes courage, wisdom, and a bit of luck!\n"; - utility::waitForEnter(); - cout - << "Professor Oak: Your mission, should you choose to accept it—and " - "trust me, you really don’t have a choice—is to collect all the " - "Pokémon Badges and conquer the Pokémon League.\n"; - utility::waitForEnter(); - - cout << "\n" - << player.name - << ": Wait... that sounds a lot like every other Pokémon game " - "out there...\n"; - utility::waitForEnter(); - cout << "Professor Oak: Shhh! Don't break the fourth wall, " - << player.name << "! This is serious business!\n"; - utility::waitForEnter(); - - cout << "\nProfessor Oak: To achieve this, you’ll need to battle wild " - "Pokémon, challenge gym leaders, and of course, keep your " - "Pokémon healthy at the PokeCenter.\n"; - utility::waitForEnter(); - cout << "Professor Oak: Along the way, you'll capture new Pokémon to " - "strengthen your team. Just remember—there’s a limit to how " - "many Pokémon you can carry, so choose wisely!\n"; - utility::waitForEnter(); - - cout << "\n" - << player.name << ": Sounds like a walk in the park... right?\n"; - utility::waitForEnter(); - cout << "Professor Oak: Hah! That’s what they all say! But beware, " - "young Trainer, the path to victory is fraught with " - "challenges. And if you lose a battle... well, let’s just say " - "you'll be starting from square one.\n"; - utility::waitForEnter(); - - cout << "\nProfessor Oak: So, what do you say? Are you ready to " - "become the next Pokémon Champion?\n"; - utility::waitForEnter(); - cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; - utility::waitForEnter(); - - cout - << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; - utility::waitForEnter(); - cout << "Professor Oak: But first... let's just pretend I didn't " - "forget to set up the actual game loop... Ahem, onwards!\n"; - utility::waitForEnter(); - } -}; - -// Function to handle the main game loop -void gameLoop(Player& player) { - int choice; - bool keepPlaying = true; - - while (keepPlaying) { - // Clear console before showing options - utility::clearConsole(); - - // Display options to the player - cout << "\nWhat would you like to do next, " << player.name << "?\n"; - cout << "1. Battle Wild Pokémon\n"; - cout << "2. Visit PokeCenter\n"; - cout << "3. Challenge Gyms\n"; - cout << "4. Enter Pokémon League\n"; - cout << "5. Quit\n"; - cout << "Enter your choice: "; - cin >> choice; - - utility::clearInputBuffer(); // Clear the input buffer - - // Process the player's choice and display the corresponding message - switch (choice) { - case 1: - cout << "You look around... but all the wild Pokémon are on " - "vacation. Maybe try again later?\n"; - break; - case 2: - cout - << "You head to the PokeCenter, but Nurse Joy is out on a coffee " - "break. Guess your Pokémon will have to tough it out for now!\n"; - break; - case 3: - cout << "You march up to the Gym, but it's closed for renovations. " - "Seems like even Gym Leaders need a break!\n"; - break; - case 4: - cout << "You boldly step towards the Pokémon League... but the " - "gatekeeper laughs and says, 'Maybe next time, champ!'\n"; - break; - case 5: - cout << "You try to quit, but Professor Oak's voice echoes: " - "'There's no quitting in Pokémon training!'\n"; - cout << "Are you sure you want to quit? (y/n): "; - char quitChoice; - cin >> quitChoice; - if (quitChoice == 'y' || quitChoice == 'Y') { - keepPlaying = false; - } - break; - default: - cout << "That's not a valid choice. Try again!\n"; - break; - } - - // Wait for Enter key before the screen is cleared and the menu is shown - // again - utility::waitForEnter(); - } - - cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; -} int main() { - // Create Pokemon and Player objects for the game - Pokemon charmander("Charmander", PokemonType::FIRE, - 100); // Using parameterized constructor - + // Continue with the main flow of the game ProfessorOak professor("Professor Oak"); - Player player("Ash", charmander); + Player player; // Greet the player and offer Pokemon choices professor.greetPlayer(player); @@ -198,7 +20,8 @@ int main() { professor.explainMainQuest(player); // Start the main game loop - gameLoop(player); + Game game; + game.gameLoop(player); return 0; } \ No newline at end of file From dd4052683b8b7a22b75ca32843a1392c5ae62bbf Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Sat, 2 Aug 2025 01:52:32 +0530 Subject: [PATCH 17/18] identifier "WildPokemon" is undefined --- Pokemon/Game.cpp | 58 ++++++++++++++++++++------------ Pokemon/Game.h | 18 +++++----- Pokemon/Grass.cpp | 2 +- Pokemon/Grass.h | 2 +- Pokemon/WildEncounterManager.cpp | 12 +++++++ Pokemon/WildEncounterManager.h | 8 +++++ Pokemon/utility.cpp | 7 ++-- Pokemon/utility.h | 5 ++- 8 files changed, 75 insertions(+), 37 deletions(-) create mode 100644 Pokemon/WildEncounterManager.cpp create mode 100644 Pokemon/WildEncounterManager.h diff --git a/Pokemon/Game.cpp b/Pokemon/Game.cpp index 75afc5f8..48391b53 100644 --- a/Pokemon/Game.cpp +++ b/Pokemon/Game.cpp @@ -1,18 +1,28 @@ #include "Game.h" -#include "player.h" +#include "Player.h" +#include "PokemonType.h" #include "utility.h" +#include "WildEncounterManager.h" +#include +using namespace std; Game::Game() { + // Create a sample grass environment with actual Pokemon objects + forestGrass = { "Forest", + {Pokemon("Pidgey", PokemonType::NORMAL, 40), + Pokemon("Caterpie", PokemonType::BUG, 35), + Pokemon("Zubat", PokemonType::POISON, 30)}, + 70 }; } -// Function to handle the main game loop void Game::gameLoop(Player& player) { + int choice; bool keepPlaying = true; while (keepPlaying) { // Clear console before showing options - utility::clearConsole(); + Utility::clearConsole(); // Display options to the player cout << "\nWhat would you like to do next, " << player.name << "?\n"; @@ -24,30 +34,35 @@ void Game::gameLoop(Player& player) { cout << "Enter your choice: "; cin >> choice; - utility::clearInputBuffer(); // Clear the input buffer + Utility::clearInputBuffer(); // Clear the input buffer // Process the player's choice and display the corresponding message switch (choice) { - case 1: - cout << "You look around... but all the wild Pokémon are on " - "vacation. Maybe try again later?\n"; + case 1: { + // Create a scope within case 1 + WildEncounterManager encounterManager; + Pokemon encounteredPokemon = encounterManager.getRandomPokemonFromGrass(forestGrass); + cout << "A wild " << encounteredPokemon.name << " appeared!\n"; break; - case 2: - cout - << "You head to the PokeCenter, but Nurse Joy is out on a coffee " + } + case 2: { + cout << "You head to the PokeCenter, but Nurse Joy is out on a coffee " "break. Guess your Pokémon will have to tough it out for now!\n"; break; - case 3: - cout << "You march up to the Gym, but it's closed for renovations. " - "Seems like even Gym Leaders need a break!\n"; + } + case 3: { + cout << "You march up to the Gym, but it's closed for renovations. Seems " + "like even Gym Leaders need a break!\n"; break; - case 4: + } + case 4: { cout << "You boldly step towards the Pokémon League... but the " "gatekeeper laughs and says, 'Maybe next time, champ!'\n"; break; - case 5: - cout << "You try to quit, but Professor Oak's voice echoes: " - "'There's no quitting in Pokémon training!'\n"; + } + case 5: { + cout << "You try to quit, but Professor Oak's voice echoes: 'There's no " + "quitting in Pokémon training!'\n"; cout << "Are you sure you want to quit? (y/n): "; char quitChoice; cin >> quitChoice; @@ -55,16 +70,17 @@ void Game::gameLoop(Player& player) { keepPlaying = false; } break; - default: + } + default: { cout << "That's not a valid choice. Try again!\n"; break; } + } // Wait for Enter key before the screen is cleared and the menu is shown // again - utility::waitForEnter(); + Utility::waitForEnter(); } cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; -} - +} \ No newline at end of file diff --git a/Pokemon/Game.h b/Pokemon/Game.h index 7189ee48..e5d3602a 100644 --- a/Pokemon/Game.h +++ b/Pokemon/Game.h @@ -1,9 +1,11 @@ -#include -class Game -{ -public: - Game(); - // Function to handle the main game loop - void gameLoop(Player& player); -}; +#include "Grass.h" + +class Player; +class Game { +private: + Grass forestGrass; +public: + Game(); + void gameLoop(Player& player); +}; \ No newline at end of file diff --git a/Pokemon/Grass.cpp b/Pokemon/Grass.cpp index 4ddd09f0..7378afdd 100644 --- a/Pokemon/Grass.cpp +++ b/Pokemon/Grass.cpp @@ -1,5 +1,5 @@ #include "Grass.h" -#include"Pokemon.h" +#include"PokemonType.h" Grass forestGrass = { "Forest", diff --git a/Pokemon/Grass.h b/Pokemon/Grass.h index 3c0c5c93..0c0c9516 100644 --- a/Pokemon/Grass.h +++ b/Pokemon/Grass.h @@ -5,7 +5,7 @@ using namespace std; struct Grass{ string environmentType; // Example: "Forest", "Cave", "Riverbank" - vector wildPokemonlist; // List of wild Pokémon that live in this grass + vector wildPokemonList; // List of wild Pokémon that live in this grass int encounterRate; // Likelihood of encountering a wild Pokémon, out of 100 }; diff --git a/Pokemon/WildEncounterManager.cpp b/Pokemon/WildEncounterManager.cpp new file mode 100644 index 00000000..63bd053e --- /dev/null +++ b/Pokemon/WildEncounterManager.cpp @@ -0,0 +1,12 @@ +#include "WildEncounterManager.h" +#include // For rand() +#include // For time() + +WildEncounterManager::WildEncounterManager() { + srand(time(0)); // Seed the random number generator +} + +WildPokemon WildEncounterManager::getRandomPokemonFromGrass(const Grass& grass) { + int randomIndex = rand() % grass.wildPokemonList.size(); + return grass.wildPokemonList[randomIndex]; +} \ No newline at end of file diff --git a/Pokemon/WildEncounterManager.h b/Pokemon/WildEncounterManager.h new file mode 100644 index 00000000..7ff1d749 --- /dev/null +++ b/Pokemon/WildEncounterManager.h @@ -0,0 +1,8 @@ +#include +#include "Grass.h" // Assuming the Grass struct is defined here + +class WildEncounterManager { +public: + WildPokemon getRandomPokemonFromGrass(const Grass& grass + ); +}; diff --git a/Pokemon/utility.cpp b/Pokemon/utility.cpp index 3ad2a280..eab18a0c 100644 --- a/Pokemon/utility.cpp +++ b/Pokemon/utility.cpp @@ -3,7 +3,7 @@ #include using namespace std; -void utility::clearConsole() { +void Utility::clearConsole() { #ifdef _WIN32 system("cls"); #else @@ -11,9 +11,10 @@ void utility::clearConsole() { #endif } -void utility::waitForEnter() { +void Utility::waitForEnter() { cin.get(); } -void utility::clearInputBuffer(){ +void Utility::clearInputBuffer(){ + cin.ignore(numeric_limits::max(), '\n'); } \ No newline at end of file diff --git a/Pokemon/utility.h b/Pokemon/utility.h index ca322012..b8849d92 100644 --- a/Pokemon/utility.h +++ b/Pokemon/utility.h @@ -1,6 +1,5 @@ -#pragma once -class utility -{ +#include +class Utility{ public : static void clearConsole(); static void waitForEnter(); From 5cdff4a446440662ef739c83a0a3ae986ee149fc Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Sat, 2 Aug 2025 01:53:56 +0530 Subject: [PATCH 18/18] identifier "WildPokemon" is undefined --- Pokemon/PokemonType.h | 5 +- Pokemon/ProfessorOak.cpp | 109 +++++++++++++++++++++++++++++++++++++++ Pokemon/ProfessorOak.h | 18 +++++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 Pokemon/ProfessorOak.cpp create mode 100644 Pokemon/ProfessorOak.h diff --git a/Pokemon/PokemonType.h b/Pokemon/PokemonType.h index 3806a62b..7ee5187a 100644 --- a/Pokemon/PokemonType.h +++ b/Pokemon/PokemonType.h @@ -4,5 +4,8 @@ enum class PokemonType { GRASS, WATER, ELECTRIC, - NORMAL // Added for the default constructor + NORMAL, + BUG, + POISON, + ROCK // Added for the default constructor }; \ No newline at end of file diff --git a/Pokemon/ProfessorOak.cpp b/Pokemon/ProfessorOak.cpp new file mode 100644 index 00000000..e710cc68 --- /dev/null +++ b/Pokemon/ProfessorOak.cpp @@ -0,0 +1,109 @@ +#include "ProfessorOak.h" +#include"utility.h" +#include "player.h" +#include + +// Parameterized constructor +ProfessorOak::ProfessorOak(string p_name) { name = p_name; } + +void ProfessorOak::greetPlayer(Player& player) { + cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; + utility::waitForEnter(); + cout << name + << ": My name is Oak. People call me the Pokemon Professor!\n"; + utility::waitForEnter(); + cout << name << ": But enough about me. Let's talk about you!\n"; + utility::waitForEnter(); +} + +void ProfessorOak::offerPokemonChoices(Player& player) { + cout + << name + << ": First, tell me, what’s your name? \t [Please Enter Your Name]\n"; + getline(cin, player.name); + cout << name << ": Ah, " << player.name + << "! What a fantastic name!\n"; + utility::waitForEnter(); + cout << name + << ": You must be eager to start your adventure. But first, " + "you’ll need a Pokemon of your own!\n"; + utility::waitForEnter(); + + // Presenting Pokemon choices + cout + << name + << ": I have three Pokemon here with me. They’re all quite feisty!\n"; + utility::waitForEnter(); + cout << name << ": Choose wisely...\n"; + cout << "1. Charmander - The fire type. A real hothead!\n"; + cout << "2. Bulbasaur - The grass type. Calm and collected!\n"; + cout << "3. Squirtle - The water type. Cool as a cucumber!\n"; + + int choice; + cout + << name + << ": So, which one will it be? Enter the number of your choice: "; + cin >> choice; + + player.choosePokemon(choice); + utility::waitForEnter(); +} + +// New method for the main quest conversation +void ProfessorOak::explainMainQuest(Player& player) { + // Clear the console + utility::clearConsole(); + + cout << "Professor Oak: " << player.name + << "!, I am about to explain you about your upcoming grand " + "adventure.\n"; + utility::waitForEnter(); + cout << "Professor Oak: You see, becoming a Pokémon Master is no easy " + "feat. It takes courage, wisdom, and a bit of luck!\n"; + utility::waitForEnter(); + cout + << "Professor Oak: Your mission, should you choose to accept it—and " + "trust me, you really don’t have a choice—is to collect all the " + "Pokémon Badges and conquer the Pokémon League.\n"; + utility::waitForEnter(); + + cout << "\n" + << player.name + << ": Wait... that sounds a lot like every other Pokémon game " + "out there...\n"; + utility::waitForEnter(); + cout << "Professor Oak: Shhh! Don't break the fourth wall, " + << player.name << "! This is serious business!\n"; + utility::waitForEnter(); + + cout << "\nProfessor Oak: To achieve this, you’ll need to battle wild " + "Pokémon, challenge gym leaders, and of course, keep your " + "Pokémon healthy at the PokeCenter.\n"; + utility::waitForEnter(); + cout << "Professor Oak: Along the way, you'll capture new Pokémon to " + "strengthen your team. Just remember—there’s a limit to how " + "many Pokémon you can carry, so choose wisely!\n"; + utility::waitForEnter(); + + cout << "\n" + << player.name << ": Sounds like a walk in the park... right?\n"; + utility::waitForEnter(); + cout << "Professor Oak: Hah! That’s what they all say! But beware, " + "young Trainer, the path to victory is fraught with " + "challenges. And if you lose a battle... well, let’s just say " + "you'll be starting from square one.\n"; + utility::waitForEnter(); + + cout << "\nProfessor Oak: So, what do you say? Are you ready to " + "become the next Pokémon Champion?\n"; + utility::waitForEnter(); + cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; + utility::waitForEnter(); + + cout + << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; + utility::waitForEnter(); + cout << "Professor Oak: But first... let's just pretend I didn't " + "forget to set up the actual game loop... Ahem, onwards!\n"; + utility::waitForEnter(); +} diff --git a/Pokemon/ProfessorOak.h b/Pokemon/ProfessorOak.h new file mode 100644 index 00000000..0b911a4e --- /dev/null +++ b/Pokemon/ProfessorOak.h @@ -0,0 +1,18 @@ +#include +using namespace std; + +// ProfessorOak class definition +class ProfessorOak { +public: + string name; + + // Parameterized constructor + ProfessorOak(string p_name); + + void greetPlayer(Player& player); + + void offerPokemonChoices(Player& player); + + // New method for the main quest conversation + void explainMainQuest(Player& player); +}; \ No newline at end of file