From 5bc00ba2d5c643401210910811f0d156de2bcd2d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 22 Mar 2026 13:46:10 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Enhance=20NumberGuess?= =?UTF-8?q?=20CLI=20UX=20with=20colors=20and=20cross-platform=20exit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add ANSI color codes (CYAN, YELLOW, RED, GREEN) for better visual feedback. * Add emojis (📉, 📈, 🎉, ❌) to improve clarity of messages. * Replace Windows-only `system("pause")` with cross-platform `cin.get()` approach. Co-authored-by: EiJackGH <172181576+EiJackGH@users.noreply.github.com> --- NumberGuess/NumberGuess.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/NumberGuess/NumberGuess.cpp b/NumberGuess/NumberGuess.cpp index c82e2f8..bfd3d54 100644 --- a/NumberGuess/NumberGuess.cpp +++ b/NumberGuess/NumberGuess.cpp @@ -5,8 +5,15 @@ using namespace std; +// ANSI Color Codes +const string RESET = "\033[0m"; +const string RED = "\033[31m"; +const string GREEN = "\033[32m"; +const string YELLOW = "\033[33m"; +const string CYAN = "\033[36m"; + void showEasterEgg() { - cout << "\n[!] EASTER EGG ACTIVATED: THE ZEN MODE" << endl; + cout << "\n" << CYAN << "[!] EASTER EGG ACTIVATED: THE ZEN MODE" << RESET << endl; cout << "Inspired by the Word 1.1a secret found 29 years later." << endl; cout << "EiJackGH Lab - Saying YES in 2026." << endl; cout << "========================================" << endl; @@ -21,7 +28,7 @@ int main() { int guess = 0; int attempts = 0; - cout << "--- EI-JACK LAB: NUMBER GUESSER V1.0 ---" << endl; + cout << CYAN << "--- EI-JACK LAB: NUMBER GUESSER V1.0 ---" << RESET << endl; cout << "I'm thinking of a number between 1 and 100." << endl; cout << "(Hint: Type 'zen' to see the credits)" << endl << endl; @@ -39,23 +46,26 @@ int main() { try { guess = stoi(input); } catch (...) { - cout << "Invalid input. Please enter a number." << endl; + cout << RED << "❌ Invalid input. Please enter a number." << RESET << endl; continue; } attempts++; if (guess > secretNumber) { - cout << ">>> Too high! Try again." << endl; + cout << YELLOW << "📉 Too high! Try again." << RESET << endl; } else if (guess < secretNumber) { - cout << ">>> Too low! Try again." << endl; + cout << YELLOW << "📈 Too low! Try again." << RESET << endl; } else { - cout << "\nCONGRATULATIONS!" << endl; + cout << "\n" << GREEN << "🎉 CONGRATULATIONS!" << RESET << endl; cout << "You found it in " << attempts << " attempts." << endl; } } cout << "----------------------------------------" << endl; - system("pause"); // Essential for Dev-C++ to keep the window open + cout << "Press Enter to exit..." << endl; + // cin >> input leaves the newline in the buffer, so we ignore it first, then get() waits for the next Enter. + cin.ignore(10000, '\n'); + cin.get(); return 0; }