diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/Prog2/Prakt1/prg2p1/mastermind/main.cpp | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Bachelor/Prog2/Prakt1/prg2p1/mastermind/main.cpp')
| -rw-r--r-- | Bachelor/Prog2/Prakt1/prg2p1/mastermind/main.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
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 <iostream>
+#include <cstdlib>
+#include <ctime>
+#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"<<endl;
+ cin >> 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));
+}
|
