Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- builder.h
- #pragma once
- #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
- #pragma once
- 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_;
- };
- ***************************************************************************************************************************************
- main.cpp
- #include "builder.h"
- #include <iostream>
- int main() {
- Wall wall{3.5, 2.5};
- Builder tom;
- std::cout << tom.CalcBricksNeeded(wall);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement