aboutsummaryrefslogtreecommitdiff
path: root/week03/Exercise2.cpp
blob: 2d7c7482ac8c4e111bef277426059c06f9fa0e19 (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
#include <iostream>
#include <cstring>

struct Alarm {
private:
	char modelName[1024];
	unsigned int pin;
	float modelRevision;

public:
	const char* getModelName() {
		return modelName;
	}
	void setModelName(const char* newModel) {
		for (int i = 0; newModel[i] != '\0'; i++) {
			if (newModel[i] < 'A' || newModel[i] > 'Z')
				return;
		}

		strcpy(modelName, newModel);
	}

	unsigned int getPin() {
		return pin;
	}
	void setPin(unsigned int newPin) {
		if (newPin > 9999) return;

		pin = newPin;
	}

	float getModelRevision() {
		return modelRevision;
	}
	void setModelRevision(float newRevision) {
		if (newRevision <= 0)
			return;

		modelRevision = newRevision;
	}
};

int main() {
	TODO
}