shushus

Спринт 5. Заголовочные файлы и файлы с реализацией. Задание 1.

Dec 12th, 2022
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. -----------------------------------------------------------------------
  2. wall.h
  3. -----------------------------------------------------------------------
  4. class Wall {
  5. public:
  6.     enum class Color { BLUE, GREEN, RED, WHITE, YELLOW };
  7.  
  8.     Wall(double width, double height);
  9.  
  10.     double GetHeight() const;
  11.     double GetWidth() const;
  12.     void SetColor(Color color);
  13.     Color GetColor() const;
  14.  
  15. private:
  16.     double width_;
  17.     double height_;
  18.     Color color_;
  19. };
  20. -----------------------------------------------------------------------
  21. wall.cpp
  22. -----------------------------------------------------------------------
  23. #include "wall.h"
  24.  
  25. Wall::Wall(double width, double height)
  26.     : width_(width)
  27.     , height_(height)
  28.     , color_(Color::WHITE) {
  29. }
  30. double Wall::GetHeight() const {
  31.     return height_;
  32. }
  33. double Wall::GetWidth() const {
  34.     return width_;
  35. }
  36. void Wall::SetColor(Color color) {
  37.     color_ = color;
  38. }
  39. Wall::Color Wall::GetColor() const {
  40.     return color_;
  41. }
  42. /*Напишите определение методов класса Wall здесь,
  43. пользуясь примером конструктора, данного выше*/
Advertisement
Add Comment
Please, Sign In to add comment