From f4c9d71aa8ee53dbcfd8f48771edd14af3b6a78a Mon Sep 17 00:00:00 2001 From: "David Vereb (Home)" Date: Sun, 24 Jan 2021 14:44:44 -0500 Subject: [PATCH] Moved my stuff away so that the initial code given to students is next to each other. --- main.cpp | 81 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/main.cpp b/main.cpp index 464953b..97fd43d 100644 --- a/main.cpp +++ b/main.cpp @@ -52,45 +52,6 @@ int main() EndGame(player); } -Player PromptForPlayer() -{ - std::string name = ""; - std::cout << "Enter your player name:" << std::endl; - std::getline(std::cin, name); - - std::string charClass_str = ""; - do - { - std::cout << std::endl << "Enter your character class, (F)ighter, (W)izard, or (R)ogue:" << std::endl; - std::getline(std::cin, charClass_str); - } while(charClass_str != "F" && - charClass_str != "W" && - charClass_str != "R"); - - CharClass charClass; - if(charClass_str == "F") - charClass = CharClass::FIGHTER; - else if(charClass_str == "W") - charClass = CharClass::WIZARD; - else if(charClass_str == "R") - charClass = CharClass::ROGUE; - - return Player(name, charClass); -} - -char PromptTravel() -{ - while(true) - { - char travel = 'K'; - std::cout << "Travel: (C)ave, (D)esert, (F)oothills, or return to the (K)ing:" << std::endl; - std::cin >> travel; - - if(travel == 'K' || travel == 'C' || travel == 'D' || travel == 'F') - return travel; - } -} - Player Intro() { // intro text & setup @@ -158,3 +119,45 @@ void EndGame(Player &player) // show total enemies killed & total gold found // THE END } + + + +// MY IMPLEMENTATION +Player PromptForPlayer() +{ + std::string name = ""; + std::cout << "Enter your player name:" << std::endl; + std::getline(std::cin, name); + + std::string charClass_str = ""; + do + { + std::cout << std::endl << "Enter your character class, (F)ighter, (W)izard, or (R)ogue:" << std::endl; + std::getline(std::cin, charClass_str); + } while(charClass_str != "F" && + charClass_str != "W" && + charClass_str != "R"); + + CharClass charClass; + if(charClass_str == "F") + charClass = CharClass::FIGHTER; + else if(charClass_str == "W") + charClass = CharClass::WIZARD; + else if(charClass_str == "R") + charClass = CharClass::ROGUE; + + return Player(name, charClass); +} + +char PromptTravel() +{ + while(true) + { + char travel = 'K'; + std::cout << "Travel: (C)ave, (D)esert, (F)oothills, or return to the (K)ing:" << std::endl; + std::cin >> travel; + + if(travel == 'K' || travel == 'C' || travel == 'D' || travel == 'F') + return travel; + } +}