S3_Cpp/Aufg2/GuestList.cpp
2024-11-11 22:47:51 +01:00

62 lines
1.0 KiB
C++

#include "GuestList.h"
#include <iostream>
#include <vector>
/*
* GästeListe
*
* Konsoleninput zur Wahl Liste verlängern/ausgeben/Ende
*/
void showMenu() {
std::cout << "1 to add Guest"
<< std::endl
<< "2 to print all Guests"
<< std::endl
<< "0 to exit"
<< std::endl;
}
void getInput(int &input) {
std::cin >> input;
}
void printAllInVector(std::vector<std::string> &Myvector) {
for (std::string name : Myvector)
{
std::cout << name
<< std::endl;
}
}
void Aufg2Main()
{
std::vector<std::string> guestList;
while (true) {
showMenu();
int input;
getInput(input);
std::string name;
switch (input)
{
case 0:
return;
case 1:
std::cin >> name;
guestList.push_back(name);
break;
case 2:
printAllInVector(guestList);
default:
break;
}
}
}