Guest User

Untitled

a guest
Dec 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include "potion.h"
  2. #include "string.h"
  3. #include <iostream>
  4. using std::cout;
  5. using std::cin;
  6. using std::endl;
  7.  
  8. potion::potion()
  9. {
  10. m_name = "minor healing potion";
  11. m_description = "heals an ammount of health";
  12. m_potency = "heals 50 health";
  13. m_cost = 1.78;
  14. m_power = 50;
  15. }
  16.  
  17. potion::potion(String name, string description, string potency, float cost, int power)
  18. {
  19. m_name = name;
  20. m_description = description;
  21. m_potency = potency;
  22. m_cost = cost;
  23. m_power = power;
  24. }
  25.  
  26. void potion::UsePotion(int playerhealth)
  27. {
  28. playerhealth += m_power;
  29. }
  30.  
  31. int potion::BuyPotion(float playercurrency)
  32. {
  33. playercurrency -= m_cost;
  34. return 1;
  35. }
  36.  
  37. void potion::SellPotion(float playercurrency)
  38. {
  39. playercurrency += (m_cost*.75);
  40. }
  41.  
  42. void potion::DisplayPotion()
  43. {
  44. cout << m_name << '\n'
  45. << m_description << '\n'
  46. << m_potency << '\n'
  47. << GetGold() << " gold " << GetSilver() << " silver " << endl;
  48. }
  49. int potion::GetGold()
  50. {
  51. int temp = m_cost;
  52. return temp;
  53. }
  54.  
  55. int potion::GetSilver()
  56. {
  57. float temp = m_cost;
  58.  
  59. int temp2 = static_cast<int>(temp);
  60.  
  61. temp -= temp2;
  62. temp *= 100;
  63. return temp;
  64. }
  65. potion::~potion()
  66. {
  67. }
Add Comment
Please, Sign In to add comment