Advertisement
Hadix

Oczko projekt bot

May 10th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.44 KB | None | 0 0
  1. #pragma once
  2. #include "Gracz.h"
  3. #include <string>
  4.  
  5. class Bot :public Gracz{
  6. private:
  7.     int numer=0;
  8.     int odwaga = 0;
  9. public:
  10.     void nadajidentyfikator(int _n);
  11.     void wypisznumer();
  12.     void nadajodwage();
  13.     void jakgrac();
  14.     void wypiszstatybota();
  15. };
  16.  
  17. #include "Bot.h"
  18. #include <iostream>
  19. #include <fstream>
  20. #include <iomanip>
  21. using namespace std;
  22.  
  23. void Bot::nadajidentyfikator (int _n) {
  24.     numer = _n+1;
  25. }
  26. void Bot::wypisznumer() {
  27.     cout << "BOT" << numer << endl;
  28. }
  29. void Bot::nadajodwage() {
  30.     cout << "Podaj poziom odwagi bota"<<numer<< endl;
  31.     while (1) {
  32.         std::cin >> odwaga;
  33.         if (std::cin.fail() == true || odwaga>=3||odwaga<0) {
  34.             std::cout << "Podaj odwage 0-2" << std::endl;
  35.             std::cin.clear();
  36.             std::cin.ignore(256, '\n');
  37.         }
  38.         else break;
  39.     }
  40. }
  41. void Bot::jakgrac() {
  42.     if (odwaga == 0) {    //zachowawczy
  43.         if (punkty <= 10) {
  44.             wezKarte();
  45.         }
  46.         else {
  47.             pas = true;
  48.         }
  49. }
  50.     if (odwaga == 1) {    //normalny
  51.         if (punkty <= 15) {
  52.             wezKarte();
  53.         }
  54.         else {
  55.             pas = true;
  56.         }
  57.     }
  58.     if (odwaga == 2) {    //ryzykujący
  59.         if (punkty <= 19) {
  60.             wezKarte();
  61.         }
  62.         else {
  63.             pas = true;
  64.         }
  65.     }
  66. }
  67. void Bot::wypiszstatybota() {
  68.     ofstream plik;
  69.     plik.open("wyniki.txt", std::ifstream::app);
  70.     plik << "BOT"<<numer << setw(17);
  71.     for (int i = 0; i < ilosckart; i++) {
  72.         plik << reka[i]->getFigura() << reka[i]->getKolor();
  73.     }
  74.     plik << setw(22 - (ilosckart * 2)) << punkty;
  75.     plik << endl;
  76.     plik.close();
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement