From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Bachelor/Prog2/Prakt1/prg2p1/mastermind/main.cpp | 73 ++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Bachelor/Prog2/Prakt1/prg2p1/mastermind/main.cpp (limited to 'Bachelor/Prog2/Prakt1/prg2p1/mastermind/main.cpp') diff --git a/Bachelor/Prog2/Prakt1/prg2p1/mastermind/main.cpp b/Bachelor/Prog2/Prakt1/prg2p1/mastermind/main.cpp new file mode 100644 index 0000000..c981178 --- /dev/null +++ b/Bachelor/Prog2/Prakt1/prg2p1/mastermind/main.cpp @@ -0,0 +1,73 @@ +#include +#include +#include +#include "mastermind.h" + +using std::cout; +using std::cin; +using std::endl; + +const int MAXROUND=8; + +void playRound(MastermindDigits&); + +int main() +{ + int menuSel=0; + int input=0; + + MastermindDigits game; + + srand(time(0)); + + do { + system ("cls"); + cout << "1: Spiel" << endl; + cout << "2: Testmodus" << endl; + cout << "Ende: beliebige Taste"<> menuSel; + switch (menuSel) + { + case 1 : + { + game.makeDigitsToGuess(); + playRound(game); + break; + } + case 2: + { + cout << "Please enter test values (1111 - 6666): "; + cin >> input; + MastermindDigits testGame(input); + playRound(testGame); + break; + } + default: menuSel=0; + } + + } while (menuSel!=0); + + return 0; +} + +void playRound(MastermindDigits& game) +{ + int tip; + int won=0; + int round=1; + + do { + cout << endl << "Ihr Tip: "; + cin >> tip; + MastermindDigits user(tip); + cout << "Position richtig: " << game.locationRight(user) << endl; + cout << "Ansonsten richtig: " << game.locationWrong(user) << endl; + if (game.locationRight(user)==4) + { + won=1; + cout << endl << "Sie haben gewonnen!" << endl; + system("pause"); + } + round++; + } while ((won==0) && (round <= MAXROUND)); +} -- cgit v1.2.3