Advertisement
LockdateforGHS

Computer_admintoolkit.playercollection.cpp

Jun 4th, 2023
1,711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. // Player structure
  6. struct Player {
  7.     int id;
  8.     std::string username;
  9. };
  10.  
  11. // Function to retrieve player information
  12. Player getPlayerInfo(const std::string& playerName) {
  13.     auto it = playerDatabase.find(playerName);
  14.     if (it != playerDatabase.end()) {
  15.         return it->second;
  16.     } else {
  17.         // Return default player if not found
  18.         return {-1, "Unknown"};
  19.     }
  20. }
  21.  
  22. // Function to count all players
  23. int countAllPlayers() {
  24.    
  25.    
  26.     return playerDatabase.size();
  27. }
  28.  
  29. // Function to check admin credentials
  30. bool isAdmin(const std::string& username, const std::string& password) {
  31.     // Replace with your admin credentials validation logic
  32.     std::string adminUsername = "admin";
  33.     std::string adminPassword = "admin123";
  34.    
  35.     return (username == adminUsername && password == adminPassword);
  36. }
  37.  
  38. int main() {
  39.     std::string adminUsername, adminPassword;
  40.     std::cout << "Admin Login\n";
  41.     std::cout << "Username: ";
  42.     std::cin >> adminUsername;
  43.     std::cout << "Password: ";
  44.     std::cin >> adminPassword;
  45.    
  46.     // Check if the entered credentials are valid
  47.     if (!isAdmin(adminUsername, adminPassword)) {
  48.         std::cout << "Invalid admin credentials. Access denied.\n";
  49.         return 0;
  50.     }
  51.    
  52.     std::string playerName;
  53.     std::cout << "\nEnter player name: ";
  54.     std::cin >> playerName;
  55.    
  56.     // Retrieve player information
  57.     Player player = getPlayerInfo(playerName);
  58.    
  59.     std::cout << "\nPlayer Info\n";
  60.     std::cout << "ID: " << player.id << std::endl;
  61.     std::cout << "Username: " << player.username << std::endl;
  62.    
  63.     // Count all players
  64.     int totalPlayers = countAllPlayers();
  65.     std::cout << "\nTotal Players: " << totalPlayers << std::endl;
  66.  
  67.     return 0;
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement