diff options
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));
+}
|
