From 44d085f265583f0e3cbef294bbe2c8e300aaa452 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 3 Apr 2024 17:47:07 +0300 Subject: [w6] Added exercise descriptions and solutions to 1-9 --- week06/Exercise01.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 week06/Exercise01.cpp (limited to 'week06/Exercise01.cpp') diff --git a/week06/Exercise01.cpp b/week06/Exercise01.cpp new file mode 100644 index 0000000..9e7a14d --- /dev/null +++ b/week06/Exercise01.cpp @@ -0,0 +1,64 @@ +#include + +struct WoodPlank { +private: + unsigned height; + unsigned width; + unsigned depth; + float price; + char type[1024]; + + void copyFrom(const WoodPlank& other) { + this->height = other.height; + this->width = other.width; + this->depth = other.depth; + this->price = other.price; + strcpy(this->type, other.type); + } + +public: + unsigned GetHeight() { + return height; + } + void SetHeight(unsigned newHeight) { + height = newHeight; + } + + unsigned GetWidth() { + return width; + } + void SetWidth(unsigned newWidth) { + width = newWidth; + } + + unsigned GetDepth() { + return depth; + } + void SetDepth(unsigned newDepth) { + depth = newDepth; + } + + float GetPrice() { + return price; + } + void SetPrice(float newPrice) { + price = newPrice; + } + + const char* GetType() { + return type; + } + void SetType(char newType[1024]) { + strcpy(type, newType); + } + + WoodPlank(const WoodPlank& other) { + copyFrom(other); + } + WoodPlank& operator=(const WoodPlank& other) { + if (this != &other) { + copyFrom(other); + } + return *this; + } +}; -- cgit v1.2.3