Guest User

Untitled

a guest
Jun 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. class food{
  2.  
  3. name;
  4. calories;
  5. weight;
  6.  
  7. public eat(name);
  8.  
  9. }
  10.  
  11. class pizza inherits food{
  12.  
  13. toppings;
  14.  
  15. say_toppings();
  16.  
  17. }
  18.  
  19. bool lid_open = false;
  20. void open_water_bottle_by_twisting() { lid_open = true; }
  21.  
  22. class Container
  23. {
  24. bool lid_open = false;
  25.  
  26. protected:
  27. Container() {}
  28. void open_by_twisting()
  29. {
  30. lid_open = true;
  31. }
  32. public:
  33. virtual ~Container();
  34. };
  35.  
  36. class WaterBottle : public Container
  37. {
  38. WaterBottle() : Container() {}
  39. public:
  40. ~WaterBottle();
  41. };
  42.  
  43. class Container
  44. {
  45. bool lid_open;
  46. bool straw_open;
  47.  
  48. protected:
  49. void TurnLid() { lid_open = true; }
  50. void BendStraw() { straw_open = true; }
  51. Container() : lid_open(false), straw_open(false){}
  52.  
  53. public:
  54. virtual void open() = 0;
  55. virtual ~Container();
  56. };
  57.  
  58. class WaterBottle : public Container
  59. {
  60.  
  61. public:
  62. WaterBottle() : Container() {}
  63. void open()
  64. {
  65. TurnLid();
  66. }
  67. ~WaterBottle();
  68. };
  69.  
  70. class ExerciseBottle : public Container
  71. {
  72. public:
  73. ExerciseBottle() : Container() {}
  74. void open()
  75. {
  76. BendStraw();
  77. }
  78. ~ExerciseBottle();
  79. };
Add Comment
Please, Sign In to add comment