aboutsummaryrefslogtreecommitdiff
path: root/week06/Exercise01.cpp
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2024-04-03 17:47:07 +0300
committerSyndamia <kamen@syndamia.com>2024-04-03 17:47:07 +0300
commit44d085f265583f0e3cbef294bbe2c8e300aaa452 (patch)
tree4899165f82a51beca1d4726db441a2749b628b9f /week06/Exercise01.cpp
parent6a8154ad7f2cbfbb2ae4f2ddda1cd0db0e430e44 (diff)
downloadoop-2023-solutions-44d085f265583f0e3cbef294bbe2c8e300aaa452.tar
oop-2023-solutions-44d085f265583f0e3cbef294bbe2c8e300aaa452.tar.gz
oop-2023-solutions-44d085f265583f0e3cbef294bbe2c8e300aaa452.zip
[w6] Added exercise descriptions and solutions to 1-9
Diffstat (limited to 'week06/Exercise01.cpp')
-rw-r--r--week06/Exercise01.cpp64
1 files changed, 64 insertions, 0 deletions
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 <cstring>
+
+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;
+ }
+};