Advertisement
chevengur

СПРИНТ № 5 | Распределение кода по файлам | Урок 3: Директива #include 1/2

Mar 7th, 2024 (edited)
969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. builder.h
  2.  
  3. #pragma once
  4. #include "wall.h"
  5. class Builder {
  6. public:
  7.     double CalcBricksNeeded(const Wall& wall) const {
  8.         double height = wall.GetHeight();
  9.         double width = wall.GetWidth();
  10.         return width * height * 5;
  11.     }
  12. };
  13. ***************************************************************************************************************************************
  14. wall.h
  15.  
  16. #pragma once
  17. class Wall {
  18. public:
  19.     Wall(double width, double height)
  20.         : width_(width)
  21.         , height_(height) {
  22.     }
  23.  
  24.     double GetHeight() const {
  25.         return height_;
  26.     }
  27.     double GetWidth() const {
  28.         return width_;
  29.     }
  30.  
  31. private:
  32.     double width_;
  33.     double height_;
  34. };
  35. ***************************************************************************************************************************************
  36. main.cpp
  37.  
  38. #include "builder.h"
  39. #include <iostream>
  40.  
  41. int main() {
  42.     Wall wall{3.5, 2.5};
  43.     Builder tom;
  44.     std::cout << tom.CalcBricksNeeded(wall);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement