Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. //BLOCK
  8. class Block
  9. {
  10. public:
  11. virtual string GetBlockName() = 0;
  12. virtual double GetHardness() = 0;
  13. virtual string GetItemFromBlock() = 0;
  14. private:
  15. };
  16.  
  17. //LIGHT EMITTING
  18. class LightEmittingBlock : public Block
  19. {
  20. public:
  21. virtual double GetLightLevel() = 0;
  22. virtual bool IsBlockEmittingLight() = 0;
  23. virtual void OnPlayerClick() = 0;
  24. double lightLevel;
  25. bool isLit;
  26. private:
  27. };
  28.  
  29. class Lamp : public LightEmittingBlock
  30. {
  31. public:
  32. string GetBlockName();
  33. double GetHardness();
  34. string GetItemFromBlock();
  35. double GetLightLevel();
  36. bool IsBlockEmittingLight();
  37. void OnPlayerClick();
  38. double lightLevel = 1;
  39. bool isLit = false;
  40. private:
  41. };
  42.  
  43. double Lamp::GetHardness()
  44. {
  45. double hardness = 0.5;
  46. return hardness;
  47. }
  48.  
  49. string GetBlockName()
  50. {
  51. string name = "Lamp";
  52. return name;
  53. }
  54.  
  55. string GetItemFromBlock()
  56. {
  57. string item = "glowstone";
  58. return item;
  59. }
  60.  
  61. double GetLightLevel(Lamp x)
  62. {
  63. double level = x.lightLevel;
  64. return level;
  65. }
  66.  
  67. void OnPlayerClick(Lamp x)
  68. {
  69. if (x.isLit == false)
  70. {
  71. x.isLit = true;
  72. }
  73.  
  74. if (x.isLit == true)
  75. {
  76. x.isLit = false;
  77. }
  78. }
  79.  
  80. //STONE
  81. class Stone : public Block
  82. {
  83. public:
  84. string GetBlockName();
  85. double GetHardness();
  86. string GetItemFromBlock();
  87. private:
  88. };
  89.  
  90. string Stone::GetBlockName()
  91. {
  92. string name = "Stone";
  93. return name;
  94. }
  95.  
  96. double Stone::GetHardness()
  97. {
  98. double hardness = 1.5;
  99. return hardness;
  100. }
  101.  
  102. string Stone::GetItemFromBlock()
  103. {
  104. string item = "Cobblestone";
  105. return item;
  106. }
  107.  
  108. //BURNABLES
  109. class BurnableBlock : public Block
  110. {
  111. public:
  112. virtual double GetBurnDuration();
  113. virtual void Burn();
  114. double burnDuration;
  115. private:
  116. };
  117.  
  118. class WoodPlanks : public BurnableBlock
  119. {
  120. public:
  121. string GetBlockName();
  122. double GetHardness();
  123. string GetItemFromBlock();
  124. double GetBurnDuration();
  125. void Burn();
  126. private:
  127. };
  128.  
  129. double WoodPlanks::GetHardness()
  130. {
  131. double hardness = 1.5;
  132. return hardness;
  133. }
  134.  
  135. string WoodPlanks::GetBlockName()
  136. {
  137. string name = "Wood Planks";
  138. return name;
  139. }
  140.  
  141. string GetItemFromBlock()
  142. {
  143. string item = "Wood Planks";
  144. return item;
  145. }
  146.  
  147. double GetBurnDuration()
  148. {
  149. double burn = 32.5;
  150. return burn;
  151. }
  152.  
  153. void Burn()
  154. {
  155. cout << "It's burning!" << endl;
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement