Wow_Rasl

Untitled

Nov 28th, 2022
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.18 KB | None | 0 0
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <fstream>
  6. #include <algorithm>
  7. #include <ctime>
  8.  
  9. using namespace std;
  10.  
  11. class Person {
  12. public:
  13.     string name;
  14.     string surname;
  15.     Person();
  16.     Person(const string& a, const string& b) {
  17.         name = a;
  18.         surname = b;
  19.     }
  20.     void Show() {
  21.         std::cout << "Name: " << name << "\nSurname: " << surname << "\n";
  22.     }
  23. };
  24.  
  25. class Gunslinger : virtual public Person {
  26. public:
  27.     Gunslinger() : Person() {};
  28.     Gunslinger(const string& a, const string& b, int cnt, double accure) : Person(a, b) {
  29.         count_ = cnt;
  30.         accuracy_ = accure;
  31.     };
  32.     double Draw() {
  33.         return accuracy_;
  34.     }
  35.  
  36.     void Show() {
  37.         std::cout << "Name: " << name << "\nSurname: " << surname << "\n"
  38.             << "Competition count : " << count_ << "\n" << "Accuracy: " << accuracy_ << "\n";
  39.     }
  40. private:
  41.     int count_;
  42.     double accuracy_;
  43. };
  44.  
  45. class PokerPlayer : virtual public Person {
  46. public:
  47.     PokerPlayer() : Person() {};
  48.     PokerPlayer(const string& a, const string& b) : Person(a, b) {};
  49.     int Draw() {
  50.         srand(time(0));
  51.         return 1 + rand() % 52;
  52.     }
  53.     void Show() {
  54.         Person::Show();
  55.     }
  56. };
  57.  
  58. class BadDude : public Gunslinger, public PokerPlayer {
  59. public:
  60.     BadDude() : Person(), Gunslinger(), PokerPlayer() {};
  61.     BadDude(const string& a, const string& b, int gun_t) : Gunslinger(a, b, 0, 0), PokerPlayer(a, b), Person(a, b) {
  62.         gun_time = gun_t;
  63.     };
  64.     double Gdraw() {
  65.         return gun_time;
  66.     }
  67.     int Cdraw() {
  68.         return PokerPlayer::Draw();
  69.     }
  70.     void Show() {
  71.         Person::Show();
  72.         std::cout << "Draw a weapon time: " << Gdraw() << endl;
  73.     }
  74. private:
  75.     double gun_time;
  76. };
  77. int main() {
  78.     Person P("Rasul", "Gainutdinov");
  79.     P.Show();
  80.  
  81.     Gunslinger Archer("Chel", "Chelov", 100, 77.1);
  82.     Archer.Show();
  83.     cout << Archer.Draw() << endl;
  84.  
  85.     PokerPlayer Player("a", "b");
  86.     Player.Show();
  87.     cout << Player.Draw() << endl;
  88.  
  89.     BadDude Doggie("Mr", "Cats", 20);
  90.     Doggie.Show();
  91.     cout << Doggie.Cdraw() << endl;
  92.  
  93.     return 0;
  94. }
  95.  
Advertisement
Add Comment
Please, Sign In to add comment