Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------
- carpenter.h
- -----------------------------------------------------------------------
- #include "wall.h"
- class Carpenter {
- public:
- int CalcShelves(const Wall& wall) const;
- };
- -----------------------------------------------------------------------
- carpenter.cpp
- -----------------------------------------------------------------------
- #include "square_calculation.h"
- #include "carpenter.h"
- int Carpenter::CalcShelves(const Wall& wall) const{
- double height = wall.GetHeight();
- double width = wall.GetWidth();
- return (int)CalcSquare(height, width)/2;
- }
- -----------------------------------------------------------------------
- wall.h
- -----------------------------------------------------------------------
- class Wall {
- public:
- enum class Color { BLUE, GREEN, RED, WHITE, YELLOW };
- Wall(double width, double height);
- double GetHeight() const;
- double GetWidth() const;
- void SetColor(Color color);
- Color GetColor() const;
- private:
- double width_;
- double height_;
- Color color_;
- };
- -----------------------------------------------------------------------
- square_calculation.h
- -----------------------------------------------------------------------
- double CalcSquare(double width, double height);
- -----------------------------------------------------------------------
- square_calculation.cpp
- -----------------------------------------------------------------------
- double CalcSquare(double height, double width) {
- return width * height;
- }
- -----------------------------------------------------------------------
- wall.cpp
- -----------------------------------------------------------------------
- #include "wall.h"
- Wall::Wall(double width, double height)
- : width_(width)
- , height_(height)
- , color_(Color::WHITE) {
- }
- double Wall::GetHeight() const {
- return height_;
- }
- double Wall::GetWidth() const {
- return width_;
- }
- void Wall::SetColor(Color color) {
- color_ = color;
- }
- Wall::Color Wall::GetColor() const {
- return color_;
- }
Advertisement
Add Comment
Please, Sign In to add comment