0% found this document useful (0 votes)
6 views10 pages

Bitag

The 'Guess the Programming Language' game is an interactive educational tool that challenges players to identify programming languages based on hints, featuring a variety of languages and a scoring system. It is a console-based application with minimal system requirements, designed for both beginners and experienced developers. Limitations include a limited question pool and lack of difficulty levels, while proposed enhancements suggest expanding content, adding explanations for answers, and improving user interface and experience.

Uploaded by

RA YS Kie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views10 pages

Bitag

The 'Guess the Programming Language' game is an interactive educational tool that challenges players to identify programming languages based on hints, featuring a variety of languages and a scoring system. It is a console-based application with minimal system requirements, designed for both beginners and experienced developers. Limitations include a limited question pool and lack of difficulty levels, while proposed enhancements suggest expanding content, adding explanations for answers, and improving user interface and experience.

Uploaded by

RA YS Kie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Introduction and Description

The "Guess the Programming Language" game is an educational and


fun way to test your knowledge of popular programming languages. Players are given hints
about different languages and must guess the correct one. The game consists of 10
questions per round, with points awarded for correct answers. After each round, your
score is displayed, and you can choose to play again. Featuring a wide variety of languages,
from common ones like JavaScript and Python to niche ones like Rust and Erlang, the
game offers a fresh experience with shuffled questions each time. It's a great way to learn
and challenge yourself while having fun!

PURPOSE
The purpose of the "Guess the Programming Language" game is to
provide an engaging and educational way for players to test and expand their knowledge of
different programming languages. It challenges players to recognize programming
languages based on descriptive hints, helping them learn about their unique characteristics
and uses. The game is designed to be fun and interactive, offering a mix of popular and
lesser-known languages, making it suitable for both beginners and experienced developers.
It encourages players to improve their memory and understanding of programming
languages while enjoying the process of learning.

SYSTEM REQUIERMENTS
The "Guess the Programming Language" game is a simple console-based
application written in C++ that requires minimal system resources. It can run on various
operating systems, including Windows, macOS, and Linux. The game has low hardware
requirements, with a minimum of 2 GB of RAM and an Intel Core i3 processor or
equivalent. It needs about 50 MB of free disk space, and integrated graphics are sufficient
for gameplay. To run the game, you will need a C++ compiler (such as GCC, MinGW, Clang,
or Visual Studio) and standard C++ libraries (C++11 or later recommended). For the best
experience, it’s recommended to have at least 4 GB of RAM, an Intel Core i5 processor, and
around 100 MB of free disk space. However, the game is lightweight and should perform
well on most modern systems that support C++ compilation and have access to a terminal
or command prompt.
Featured
The "Guess the Programming Language" game offers several engaging features that
make it both educational and fun:

1. Variety of Programming Languages: The game includes a wide range of


programming languages, from popular ones like JavaScript, Python, and Java, to
more niche languages such as Erlang and Rust, allowing players to learn about
different languages.
2. Randomized Questions: The questions are shuffled every time you play, ensuring a
fresh experience with each round and increasing replayability.
3. Educational and Fun: Players test their knowledge of programming languages by
guessing based on descriptive hints, learning interesting facts about the languages
along the way.
4. Scoring System: Players earn points for each correct answer, with their score
displayed at the end of the game, providing a sense of accomplishment and
competition.
5. Replayability: After each round, players can choose to play again, which
encourages repeated play to improve scores and reinforce learning.
6. Simple and Accessible: The game is a console-based application, making it easy to
run on various systems without requiring advanced hardware or software.
7. User-friendly Interface: The game provides clear instructions and easy-to-follow
prompts, making it accessible for both beginners and experienced players.

Code Structure
Header files:
#include <iostream> // This header file is part of the C++ Standard Library and is used to handle
input and output. It provides functionality for outputting information to the console (using std::cout)
and receiving input from the user (using std::cin).
#include <map> // The map header provides the std::map container, which is a collection of key-
value pairs, where each key is unique. In this game, std::map is used to store the programming hints
(as keys) and the corresponding programming languages (as values).
#include <vector> // The vector header provides the std::vector container, which is a
dynamic array that can resize itself automatically when elements are added or removed.
#include <cstdlib> // The cstdlib header provides functions for general purpose utilities
such as memory allocation, process control, and random number generation.
#include <ctime> // This header defines functions to manipulate and format time. It is used in
conjunction with std::rand() for seeding the random number generator using the current time.
#include <algorithm> The algorithm header provides a variety of functions to perform
operations on containers like vectors and arrays. In this game, std::transform is used to convert
strings to lowercase (for case-insensitive comparisons), and std::shuffle is used to randomly shuffle
the questions.
#include <random> // For std::shuffle
Main Function

// Function to shuffle the questions


void shuffleQuestions(vector<pair<string, string>>& questions) {
shuffle(questions.begin(), questions.end(),
default_random_engine(time(0)));
}

// Function to convert a string to lowercase for case-insensitive


comparison
string toLowerCase(const string& str) {
string lowerStr = str;
transform(lowerStr.begin(), lowerStr.end(),
lowerStr.begin(), ::tolower);
return lowerStr;
}

// Function to trim whitespace from a string


string trim(const string& str) {
size_t first = str.find_first_not_of(" \t\n\r");
size_t last = str.find_last_not_of(" \t\n\r");
return (first == string::npos || last == string::npos) ? "" :
str.substr(first, last - first + 1);
}

// Function to get the player's guess


string getUserGuess() {
string guess;
cout << "\nYour guess: ";
getline(cin, guess);

guess = trim(guess); // Remove extra whitespace

// Check if the input is empty


if (guess.empty()) {
cout << "You didn't enter anything. Please provide an answer.\n";
return getUserGuess(); // Recurse until the user enters a valid
guess
}

return guess;
}
// Function to play the programming language game
void playGame() {
// Map of hints and corresponding programming languages
map<string, string> programmingHints = {
// < hints and Answer >
{"Known for its flexibility.", "JavaScript"},
{"Statically typed, commonly used for Android development.",
"Java"},
{"Known for its simplicity and readability.", "Python"},
{"Used for system-level programming and operating systems.",
"C"},
{"Object-oriented, commonly used in game development.", "C++"},
{"Used for building dynamic web applications, known for
frameworks like Rails.", "Ruby"},
{"Functional programming language used in web applications like
WhatsApp.", "Erlang"},
{"Developed by Google, used for performance-critical
applications.", "Go"},
{"Scripting language used for server-side web development.",
"PHP"},
{"Data science and machine learning favorite.", "R"},
{"Developed by Microsoft, used for Windows apps.", "C#"},
{"General-purpose language created by Bjarne Stroustrup.", "C+
+"},
{"Cross-platform mobile app development framework by Google.",
"Dart"},
{"Functional-first language that runs on the .NET runtime.",
"F#"},
{"Created for statistical computing and graphics.", "R"},
{"A language often used for embedded systems and
microcontrollers.", "C"},
{"A powerful and fast programming language used in high-
performance applications.", "Rust"},
{"A programming language focused on simplicity, used in web
development.", "Go"},
{"A statically typed, compiled programming language designed for
scalability.", "Swift"},
{"A general-purpose, high-level language used for software and
web applications.", "JavaScript"},
{"Used for scientific computing and artificial intelligence.",
"Julia"},
{"A language designed to be simple and efficient for numerical
computing.", "Matlab"},
{"Popular for cross-platform applications and mobile apps.",
"Kotlin"},
{"A powerful, open-source language for web development and
scripting.", "Python"},
{"Used for large-scale enterprise applications and database
systems.", "SQL"},
{"Used for creating websites and web applications.", "HTML"},
{"A lightweight, interpreted language often used for server-side
web development.", "Node.js"}
};

// Store questions as vector pairs


vector<pair<string, string>> questions(programmingHints.begin(),
programmingHints.end());

// Shuffle the questions for randomness


shuffleQuestions(questions);

int score = 0; // Player's score


int questionCount = 10; // Number of questions per round

// Ask questions with numbered format


for (int i = 0; i < questionCount && i < questions.size(); i++) {
auto& question = questions[i]; // Access each pair
string hint = question.first; // Extract the hint
string answer = question.second; // Extract the answer

// Modify question format to ask the user to guess based on the


hint
cout << "\nGuess " << i + 1 << ": Guess the programming language:
" << hint << endl;

string userGuess = toLowerCase(getUserGuess());


string normalizedAnswer = toLowerCase(answer);

if (userGuess == normalizedAnswer) {
cout << "Correct! The answer is: " << answer << ".\n";
score++;
} else {
cout << "Wrong! The correct answer was: " << answer << ".\n";
}
}

// Display final score for programming language game


cout << "\nGame Over! Your final score in the programming language
game is: " << score << "/" << questionCount << endl;
}
int main() {
string playerName;
char playAgain;

// Display game instructions


cout << "Welcome to the Guess the Programming Language Game!\n";
cout << "In this game, you will be given a hint describing a popular
programming language.\n";
cout << "Your task is to guess the programming language based on the
hint.\n";
cout << "You will have 10 questions to answer, and each correct
answer will earn you 1 point.\n";
cout << "At the end of the game, your total score will be displayed.\
n";
cout << "Good luck, and let's see how many programming languages you
can guess correctly!\n\n";

// Ask for the player's name and greet them


cout << "Please enter your name: ";
getline(cin, playerName);
cout << "Hello, " << playerName << "! Let's get started.\n";

do {
// Play the game
playGame();

// Ask the user if they want to play again


cout << "\nDo you want to play again? (y/n): ";
cin >> playAgain;

// Clear the input buffer to avoid issues with getline in the


next round
cin.ignore(numeric_limits<streamsize>::max(), '\n');
} while (playAgain == 'y' || playAgain == 'Y');

cout << "\nThanks for playing, " << playerName << "! Goodbye!\n";
return 0;
}
Sample Input and Output with screenshot
limitations
The "Guess the Programming Language" game has several limitations. It currently offers a
limited number of questions, which can make the game repetitive for players after multiple
rounds. Additionally, there are no difficulty levels to adjust the game for beginners or experts.
The absence of a timer or time-based scoring mechanism reduces the challenge, as players can
take as long as they need to answer. When players guess incorrectly, the game only reveals the
correct answer without offering explanations, which limits the educational value. The game also
lacks progress tracking, high scores, or statistics to motivate players. Furthermore, the text-based
interface may not appeal to players who prefer more interactive or visually engaging
experiences, and the input handling is basic, offering no support for typos or alternate valid
answers.

Enhancements
To enhance the game, several improvements could be made. Expanding the question pool would
keep the game fresh and engaging for players. Introducing difficulty levels would cater to
players of varying skill levels, while adding a timer could make the game more exciting and
competitive. Providing explanations for incorrect answers would make the game more
educational, helping players learn about programming languages. Implementing high-score
tracking or leaderboards would allow players to track their progress. A graphical user interface
(GUI) could make the game more visually appealing, and enhanced input validation could
improve the user experience by handling typos and alternative answers. Additionally, a
multiplayer mode would allow players to compete against each other, and mobile or web
versions of the game would make it more accessible. Lastly, offering customizable questions or
categories would allow players to tailor the game to their interests. These enhancements would
make the game more engaging, educational, and accessible to a wider audience.

You might also like