Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <ctime>
- #include <locale.h>
- #include <windows.h>
- using namespace std;
- // Alla val i menyn:
- void meny();
- char val;
- void insattning();
- void satsning();
- void saldo();
- void banditen();
- void avslutaSpel();
- void vinstRegler();
- int tal1; //Summa för insättning
- int tal2; //Summma för satsning
- int saldo1 = 0;
- int vinster();
- // Variabler för själv spelet:
- int main()
- {
- srand(time(0));
- setlocale(LC_ALL, "swedish");
- meny();
- insattning();
- saldo();
- satsning();
- banditen();
- return 0;
- }
- void meny() {
- while (true) {
- system("cls");
- cout << " Välkommen till Enarmade Banditen " << endl << endl;
- cout << " För att sätt in pengar tryck K " << endl << endl;
- cout << " För att kolla Saldo tryck S " << endl << endl;
- cout << " För att satsa pengar tryck P " << endl << endl;
- cout << " För att spela Enarmade Banditen tryck B " << endl << endl;
- cout << " För att avsluta spelet tryck A " << endl << endl;
- cout << " För att läsa vinstregler tryck R" << endl << endl;
- cin >> val;
- if (cin.fail()) {
- cin.clear();
- cin.ignore();
- cout << "Du har valt ett ogiltigt alternativ!" << endl << endl;
- system("pause");
- system("cls");
- }
- else if ((val == 'K' || val == 'k')) {
- insattning();
- }
- else if ((val == 'S' || val == 's')) {
- saldo();
- }
- else if ((val == 'P' || val == 'p')) {
- satsning();
- }
- else if ((val == 'B' || val == 'b')) {
- banditen();
- }
- else if ((val == 'R' || val == 'r')) {
- vinstRegler();
- }
- else if ((val == 'A' || val == 'a')) {
- avslutaSpel();
- }
- }
- }
- void insattning() {
- system("cls");
- while (true) {
- cout << " Mata in ett tal för insättning 100, 300 eller 500 " << endl;
- cin >> tal1;
- if (tal1 == 100 || tal1 == 300 || tal1 == 500) {
- cout << " Din insättning är Godkänd! " << endl;
- saldo1 = saldo1 + tal1;
- break;
- }
- else {
- cout << " Vänligen välj 100, 300 eller 500 " << endl;
- }
- }
- }
- void saldo() {
- while (val == 's' || val == 'S') {
- cout << " Ditt saldo är nu: " << saldo1 << endl;
- saldo1 = saldo1 + tal1;
- system("pause");
- break;
- }
- }
- void banditen() {
- system("cls");
- cout << "Välkommen till speler Enarmade banditen!" << endl << endl;
- cout << " Din satsning är: " << tal2 << endl;
- //Här sker spelet
- char spelplan[3][3];
- for (int x = 0; x < 3;x++) {
- for (int o = 0; o < 3;o++) {
- int line = rand() % 3 + 1;
- if (line == 1) {
- spelplan[x][o] = '!';
- }
- else if (line == 2) {
- spelplan[x][o] = '*';
- }
- else if (line == 3) {
- spelplan[x][o] = 'O';
- }
- cout << " " << spelplan[x][o] << " ";
- }
- system("pause");
- }
- }
- int vinster() {
- int vinst;
- for (int vinst line ==1) {
- }
- //if blabla
- //vinst++
- return vinst;
- }
- void avslutaSpel() {
- system("cls");
- cout << " Du har valt att avsluta spelet" << endl << endl;
- cout << " Hoppas vi ses igen!" << endl << endl;
- Sleep(500);
- exit(0);
- }
- void vinstRegler() {
- system("cls");
- while (val == 'r' || val == 'R') {
- cout << " Vinstregler " << endl << endl;
- cout << " Vinst = 3 lika symboler " << endl << endl;
- cout << " En rad ger 2 * insatsen " << endl << endl;
- cout << " Två rader ger 3 * insatsen " << endl << endl;
- cout << " Tre rader ger 4 * insatsen " << endl << endl;
- cout << " Fyra rader ger 5 * insatsen " << endl << endl;
- cout << " Fem rader ger 7 * insatsen " << endl << endl;
- cout << " Fullt spelfält ger 10 * insatsen " << endl << endl;
- cout << " " << endl << endl;
- system("pause");
- break;
- }
- }
- void satsning() {
- system("cls");
- while (true) {
- cout << " Mata in en summa du vill Satsa i spelet " << endl << endl;
- cin >> tal2;
- if (tal2 <= saldo1) {
- saldo1 = saldo1 - tal2;
- break;
- }
- else {
- cout << "Ditt saldo matchar inte din satsning.." << endl << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement