#include <iostream>
#include <map>
#include <string>
using namespace std;

int main()
{
   cout << "Aufgabe 10.5 - Telefonbuch 1\n\n";

   map<string, string> book;
   book.insert({ "max", "123 456" });
   book.insert({ "heinrich", "777 777" });
   book.insert({ "eva", "+12 (0)(0) 4567-4" });
   book.insert({ "tom otto", "997755" });
   book.insert({ "charlotte", "123" });

   for (;;)
   {
      cout << "\nEingabe: ";
      string input;
      getline(cin, input);
      cout << '\n';

      if (input == "list")
      {
         for (auto [name, no] : book)
         {
            cout << name << " -> " << no << '\n';
         }
      }
      else if (input == "end")
      {
         break;
      }
      else
      {
         auto fit = book.find(input);
         if (fit == cend(book))
         {
            cout << "Der Name " << input << " wurde nicht gefunden\n";
         }
         else
         {
            cout << "=> " << fit->first << " -> " << fit->second << '\n';
         }
      }
   }
   cout << "Auf Wiedersehen\n";
}
