Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "Gracz.h"
- #include <string>
- class Bot :public Gracz{
- private:
- int numer=0;
- int odwaga = 0;
- public:
- void nadajidentyfikator(int _n);
- void wypisznumer();
- void nadajodwage();
- void jakgrac();
- void wypiszstatybota();
- };
- #include "Bot.h"
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- void Bot::nadajidentyfikator (int _n) {
- numer = _n+1;
- }
- void Bot::wypisznumer() {
- cout << "BOT" << numer << endl;
- }
- void Bot::nadajodwage() {
- cout << "Podaj poziom odwagi bota"<<numer<< endl;
- while (1) {
- std::cin >> odwaga;
- if (std::cin.fail() == true || odwaga>=3||odwaga<0) {
- std::cout << "Podaj odwage 0-2" << std::endl;
- std::cin.clear();
- std::cin.ignore(256, '\n');
- }
- else break;
- }
- }
- void Bot::jakgrac() {
- if (odwaga == 0) { //zachowawczy
- if (punkty <= 10) {
- wezKarte();
- }
- else {
- pas = true;
- }
- }
- if (odwaga == 1) { //normalny
- if (punkty <= 15) {
- wezKarte();
- }
- else {
- pas = true;
- }
- }
- if (odwaga == 2) { //ryzykujący
- if (punkty <= 19) {
- wezKarte();
- }
- else {
- pas = true;
- }
- }
- }
- void Bot::wypiszstatybota() {
- ofstream plik;
- plik.open("wyniki.txt", std::ifstream::app);
- plik << "BOT"<<numer << setw(17);
- for (int i = 0; i < ilosckart; i++) {
- plik << reka[i]->getFigura() << reka[i]->getKolor();
- }
- plik << setw(22 - (ilosckart * 2)) << punkty;
- plik << endl;
- plik.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement