Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <time.h>
  4.  
  5. class Pokemon
  6. {
  7. protected:
  8. int m_dex_num;
  9. float m_catch_rate;
  10. std::string m_type;
  11. public:
  12. Pokemon(int dex_num, int catch_rate, std::string type)
  13. : m_dex_num(dex_num), m_catch_rate(catch_rate), m_type(type) {}
  14.  
  15. int dex_num() const { return m_dex_num; }
  16. float catch_rate() const { return m_catch_rate; }
  17. std::string type() const { return m_type; }
  18.  
  19. virtual bool attempt_catch() = 0;
  20. };
  21.  
  22. class Castform : public Pokemon
  23. {
  24. private:
  25. std::string m_forms[3] = { "sunny", "rainy", "snowy" };
  26. public:
  27. Castform() : Pokemon(351, 11.9, "normal") {}
  28.  
  29. bool attempt_catch() {
  30. srand(time(NULL));
  31. return (rand() % 100) < m_catch_rate;
  32. }
  33. };
  34.  
  35. int main()
  36. {
  37. auto wild_castform = Castform();
  38.  
  39. std::cout << "Wild Castform appeared!n";
  40. std::cout << "Dex number " << wild_castform.dex_num() << 'n';
  41. std::cout << "It's a " << wild_castform.type() << " typen";
  42.  
  43. for(int i=0; i < 5; ++i) {
  44. std::cout << "Catch attempt resulted in " << wild_castform.attempt_catch() << 'n';
  45. }
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement