From 430a8225c5e4bb7cea582f6ab2751b66a84e1dd6c21225a6f30d486e7870c074 Mon Sep 17 00:00:00 2001 From: Tyler Beckman Date: Sun, 1 Sep 2024 23:31:56 -0600 Subject: [PATCH] Reformat --- hands.cpp | 32 ++++++++++++++++++++++---------- main.cpp | 3 +-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/hands.cpp b/hands.cpp index bb97e04..6843881 100644 --- a/hands.cpp +++ b/hands.cpp @@ -4,6 +4,7 @@ #include #include #include + #include std::unique_ptr Hand::fromChar(const char letter) { @@ -36,7 +37,9 @@ std::unique_ptr Hand::generateRandom() { case 2: return std::make_unique(); default: - std::cerr << "An invalid random number was generated, this should be impossible" << std::endl; + std::cerr << "An invalid random number was generated, this should " + "be impossible" + << std::endl; std::exit(1); } } @@ -47,25 +50,34 @@ std::string Rock::getHandName() const { return "rock"; } GameResult Rock::compareAgainst(const Hand &other) { const std::string otherName = other.getHandName(); - if (otherName == "rock") return GameResult::Tie; - if (otherName == "scissors") return GameResult::Win; - else return GameResult::Loss; + if (otherName == "rock") + return GameResult::Tie; + if (otherName == "scissors") + return GameResult::Win; + else + return GameResult::Loss; } std::string Paper::getHandName() const { return "paper"; } GameResult Paper::compareAgainst(const Hand &other) { const std::string otherName = other.getHandName(); - if (otherName == "paper") return GameResult::Tie; - if (otherName == "rock") return GameResult::Win; - else return GameResult::Loss; + if (otherName == "paper") + return GameResult::Tie; + if (otherName == "rock") + return GameResult::Win; + else + return GameResult::Loss; } std::string Scissors::getHandName() const { return "scissors"; } GameResult Scissors::compareAgainst(const Hand &other) { const std::string otherName = other.getHandName(); - if (otherName == "scissors") return GameResult::Tie; - if (otherName == "paper") return GameResult::Win; - else return GameResult::Loss; + if (otherName == "scissors") + return GameResult::Tie; + if (otherName == "paper") + return GameResult::Win; + else + return GameResult::Loss; } \ No newline at end of file diff --git a/main.cpp b/main.cpp index 65cba09..1280e09 100644 --- a/main.cpp +++ b/main.cpp @@ -11,8 +11,7 @@ int main(void) { while (true) { // Take a letter input and convert it to the correct class type for - // later - // use + // later use char handLetter; std::cout << "Welcome to a round of Rock Paper Scissors! Please enter " "a hand to play (R/P/S): ";