Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- // Player structure
- struct Player {
- int id;
- std::string username;
- };
- // Function to retrieve player information
- Player getPlayerInfo(const std::string& playerName) {
- auto it = playerDatabase.find(playerName);
- if (it != playerDatabase.end()) {
- return it->second;
- } else {
- // Return default player if not found
- return {-1, "Unknown"};
- }
- }
- // Function to count all players
- int countAllPlayers() {
- return playerDatabase.size();
- }
- // Function to check admin credentials
- bool isAdmin(const std::string& username, const std::string& password) {
- // Replace with your admin credentials validation logic
- std::string adminUsername = "admin";
- std::string adminPassword = "admin123";
- return (username == adminUsername && password == adminPassword);
- }
- int main() {
- std::string adminUsername, adminPassword;
- std::cout << "Admin Login\n";
- std::cout << "Username: ";
- std::cin >> adminUsername;
- std::cout << "Password: ";
- std::cin >> adminPassword;
- // Check if the entered credentials are valid
- if (!isAdmin(adminUsername, adminPassword)) {
- std::cout << "Invalid admin credentials. Access denied.\n";
- return 0;
- }
- std::string playerName;
- std::cout << "\nEnter player name: ";
- std::cin >> playerName;
- // Retrieve player information
- Player player = getPlayerInfo(playerName);
- std::cout << "\nPlayer Info\n";
- std::cout << "ID: " << player.id << std::endl;
- std::cout << "Username: " << player.username << std::endl;
- // Count all players
- int totalPlayers = countAllPlayers();
- std::cout << "\nTotal Players: " << totalPlayers << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement