Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include "AnimalClass.h"
  2. #include <iostream>
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4.  
  5. int main() {
  6. lmao::AnimalClass bleh();
  7. bleh.eat();
  8. bleh.walk();
  9.  
  10. return 0;
  11. }
  12.  
  13.  
  14. #define ANIMALCLASS_H
  15. #ifndef ANIMALCLASS_H
  16.  
  17. namespace lmao
  18. {
  19. class AnimalClass
  20. {
  21. public:
  22. AnimalClass();
  23. void checkEnergy();
  24. void eat();
  25. void walkAround();
  26. int energyLevel;
  27.  
  28. };
  29. }
  30. #endif
  31.  
  32.  
  33. #include "AnimalClass.h"
  34. #include <iostream>
  35.  
  36. namespace lmao
  37. {
  38. AnimalClass::AnimalClass()
  39. :energyLevel(0)
  40. {
  41. std::cout << "Animal created" << std::endl;
  42. }
  43. void AnimalClass::eat()
  44. {
  45. energyLevel += 5;
  46. std::cout << "Your animal just ate" << std::endl;
  47. }
  48. void AnimalClass::walkAround()
  49. {
  50. energyLevel -= 3;
  51. std::cout <<"Your animal just walked around and consumed some energy" <<std::endl;
  52. }
  53. void AnimalClass::checkEnergy()
  54. {
  55. std::cout << "You have " << energyLevel << " energy" << std::endl;
  56. }
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement