aboutsummaryrefslogtreecommitdiff
path: root/week06/Exercise01.cpp
blob: 9e7a14d632fb5fc10909703a5c16c30f92f9c81e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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;
	}
};