Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------
- main.cpp
- -----------------------------------------------------------------------
- #include <iostream>
- #include "builder.h"
- using namespace std;
- int main() {
- Wall wall(3.5, 2.45);
- Builder tom;
- // Попросите Тома посчитать кирпичи для стены 3.5 х 2.45
- const auto num_of_bricks = tom.CalcBricksNeeded(wall);
- cout<<num_of_bricks;
- }
- -----------------------------------------------------------------------
- builder.h
- -----------------------------------------------------------------------
- #include "wall.h"
- class Builder {
- public:
- double CalcBricksNeeded(const Wall& wall) const {
- double height = wall.GetHeight();
- double width = wall.GetWidth();
- return width * height * 5;
- }
- };
- -----------------------------------------------------------------------
- wall.h
- -----------------------------------------------------------------------
- class Wall {
- public:
- Wall(double width, double height)
- : width_(width)
- , height_(height) {
- }
- double GetHeight() const {
- return height_;
- }
- double GetWidth() const {
- return width_;
- }
- private:
- double width_;
- double height_;
- };
Advertisement
Add Comment
Please, Sign In to add comment