daily pastebin goal
92%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <memory>
  4.  
  5. using namespace std;
  6.  
  7. class Sklep {
  8. public:
  9.     virtual void getCena() const = 0;
  10.     virtual void getOpis() = 0;
  11.     virtual ~Sklep() {};
  12. };
  13.  
  14. class KrwiRewoler: public Sklep {
  15. public:
  16.     virtual void getCena() const {
  17.         cout << "20000 jednostek" << endl;
  18.     }
  19.     virtual void getOpis() {
  20.         cout << "Atak: 100\nSzybkosc ataku: 3\n";
  21.     }
  22. };
  23. class PlazmowyKarabin: public Sklep {
  24. public:
  25.  
  26.     virtual void getCena() const {
  27.         cout << "50000 jednostek" << endl;
  28.     }
  29.     virtual void getOpis() {
  30.         cout << "Atak: 240\nSzybkosc ataku: 2\n";
  31.     }
  32. };
  33. class MiotaczPlomieni: public Sklep {
  34.     virtual void getCena() const {
  35.         cout << "100000 jednostek" << endl;
  36.     }
  37.     virtual void getOpis() {
  38.         cout << "Atak: 350\nSzybkosc ataku: 4\n";
  39.     }
  40. };
  41. class Karabin: public Sklep{
  42.     virtual void getCena() const {
  43.         cout << "450000 jednostek" << endl;
  44.     }
  45.     virtual void getOpis() {
  46.         cout << "Atak: 550\nSzybkosc ataku: 5\n";
  47.     }
  48. };
  49. class Rakietnica: public Sklep {
  50.     virtual void getCena() const {
  51.         cout << "100000 jednostek" << endl;
  52.     }
  53.     virtual void getOpis() {
  54.         cout << "Atak: 1200\nSzybkosc ataku: 3\n";
  55.     }
  56. };
  57.  
  58.  
  59.  
  60. class KreatorBroni {
  61. public:
  62.     static Sklep* kup_bron(int x) {
  63.         if (x == 1)
  64.             return new KrwiRewoler();
  65.        
  66.         else if (x == 2)
  67.             return new PlazmowyKarabin();
  68.     }
  69. };
  70.  
  71. int main()
  72. {
  73.     std::auto_ptr<const Sklep> sklep(KreatorBroni::kup_bron(1));
  74.     sklep->getCena();
  75.  
  76.    
  77.  
  78.     getchar();
  79.     getchar();
  80.     return 0;
  81. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top