Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - accountant.h
 - #pragma once
 - #include "wall.h"
 - #include "square_calculation.h"
 - class Accountant {
 - public:
 - template <class BuildingObject>
 - double CalcPaintNeeded(const BuildingObject& building_object) const;
 - template <class BuildingObject>
 - double CalcBricksNeeded(const BuildingObject& building_object) const;
 - };
 - template <class BuildingObject>
 - double Accountant::CalcPaintNeeded(const BuildingObject& building_object) const {
 - std::pair<double, double> sizes = building_object.GetSizes();
 - return CalcSquare(sizes.first, sizes.second) * 0.4;
 - }
 - template <class BuildingObject>
 - double Accountant::CalcBricksNeeded(const BuildingObject& building_object) const {
 - std::pair<double, double> sizes = building_object.GetSizes();
 - return CalcSquare(sizes.first, sizes.second) * 5;
 - }
 - ***************************************************************************************************************************************
 - builder.h
 - #pragma once
 - #include "square_calculation.h"
 - class Builder {
 - public:
 - void HoldDoor() const {
 - // Просто держит дверь 100 условных секунд
 - int i = 100;
 - while (0 != i) {
 - i--;
 - }
 - }
 - };
 - ***************************************************************************************************************************************
 - carpanter.cpp
 - #include "carpenter.h"
 - #include "square_calculation.h"
 - int Carpenter::CalcShelves(const Wall& wall) const {
 - double height = wall.GetHeight();
 - double width = wall.GetWidth();
 - return CalcSquare(width, height) / 2;
 - }
 - void Carpenter::InstallDoor(Wall& wall, const Builder& builder) const {
 - // Hold the door, builder! Hold the door!
 - builder.HoldDoor();
 - wall.SetDoorInstalled();
 - }
 - ***************************************************************************************************************************************
 - carpanter.h
 - #pragma once
 - #include "builder.h"
 - #include "wall.h"
 - class Carpenter {
 - public:
 - int CalcShelves(const Wall& wall) const;
 - void InstallDoor(Wall& wall, const Builder& builder) const;
 - };
 - ***************************************************************************************************************************************
 - ceiling.cpp
 - #include "ceiling.h"
 - Ceiling::Ceiling(double length, double width)
 - : length_(length)
 - , width_(width) {
 - }
 - std::pair<double, double> Ceiling::GetSizes() const {
 - return {length_, width_};
 - }
 - ***************************************************************************************************************************************
 - ceiling.h
 - #pragma once
 - #include <utility>
 - class Ceiling {
 - public:
 - Ceiling(double length, double width);
 - std::pair<double, double> GetSizes() const;
 - private:
 - double length_;
 - double width_;
 - };
 - ***************************************************************************************************************************************
 - main.cpp
 - #include <iostream>
 - #include "accountant.h"
 - #include "ceiling.h"
 - #include "roof.h"
 - using namespace std;
 - int main() {
 - Accountant ray;
 - Wall wall(3.5, 2.45);
 - Roof roof(5, 7);
 - Ceiling ceiling(5, 7);
 - cout << "Требуется кирпичей: "s
 - << ray.CalcBricksNeeded<Wall>(wall) + ray.CalcBricksNeeded<Roof>(roof)
 - + ray.CalcBricksNeeded<Ceiling>(ceiling)
 - << endl;
 - cout << "Требуется краски: "s
 - << ray.CalcPaintNeeded<Wall>(wall) + ray.CalcPaintNeeded<Roof>(roof)
 - + ray.CalcPaintNeeded<Ceiling>(ceiling)
 - << endl;
 - return 0;
 - }
 - ***************************************************************************************************************************************
 - painter.h
 - #pragma once
 - #include "square_calculation.h"
 - #include "wall.h"
 - class Painter {
 - public:
 - void Paint(Wall& wall, Wall::Color color) const {
 - wall.SetColor(color);
 - }
 - };
 - ***************************************************************************************************************************************
 - roof.cpp
 - #include "roof.h"
 - Roof::Roof(double length, double width)
 - : length_(length)
 - , width_(width) {
 - }
 - std::pair<double, double> Roof::GetSizes() const {
 - return {length_, width_};
 - }
 - ***************************************************************************************************************************************
 - square_calculation.cpp
 - #include "square_calculation.h"
 - double CalcSquare(double width, double height) {
 - return width * height;
 - }
 - ***************************************************************************************************************************************
 - square_calculation.h
 - #pragma once
 - double CalcSquare(double width, double height);
 - ***************************************************************************************************************************************
 - wall.cpp
 - #include "wall.h"
 - Wall::Wall(double width, double height)
 - : width_(width)
 - , height_(height)
 - , color_(Color::WHITE)
 - , is_door_installed_(false) {
 - }
 - double Wall::GetHeight() const {
 - return height_;
 - }
 - double Wall::GetWidth() const {
 - return width_;
 - }
 - std::pair<double, double> Wall::GetSizes() const {
 - return {width_, height_};
 - }
 - void Wall::SetColor(Color color) {
 - color_ = color;
 - }
 - Wall::Color Wall::GetColor() const {
 - return color_;
 - }
 - bool Wall::IsDoorInstalled() const {
 - return is_door_installed_;
 - }
 - void Wall::SetDoorInstalled() {
 - is_door_installed_ = true;
 - }
 - ***************************************************************************************************************************************
 - wall.h
 - #pragma once
 - #include <utility>
 - class Wall {
 - public:
 - enum class Color { BLUE, GREEN, RED, WHITE, YELLOW };
 - Wall(double width, double height);
 - double GetHeight() const;
 - double GetWidth() const;
 - std::pair<double, double> GetSizes() const;
 - void SetColor(Color color);
 - Color GetColor() const;
 - bool IsDoorInstalled() const;
 - void SetDoorInstalled();
 - private:
 - double width_;
 - double height_;
 - Color color_;
 - bool is_door_installed_;
 - };
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment