blob: 09e12868fcebcb4109811b0896ed0b6942a02cb4 (
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
|
#include <cstring>
struct Smartphone {
private:
char brand[129];
char model[513];
unsigned manufacturingYear;
float cameraResolution;
public:
const char* GetBrand() {
return brand;
}
void SetBrand(const char* newValue) {
if (newValue[0] == '\0' || strlen(newValue) > 128) {
throw "Brand cannot be empty string or longer than 128 characters!";
}
strcpy(brand, newValue);
}
const char* GetModel() {
return model;
}
void SetModel(const char* newValue) {
if (newValue[0] == '\0' || strlen(newValue) > 512) {
throw "Model cannot be empty string or longer than 512 characters!";
}
strcpy(model, newValue);
}
unsigned GetManufacturingYear() {
return manufacturingYear;
}
void SetManufacturingYear(unsigned newValue) {
if (newValue < 2000 || 2024 < newValue) {
throw "Manufacturing year cannot be before 2000 or after 2024!";
}
manufacturingYear = newValue;
}
float GetCameraResolution() {
return cameraResolution;
}
void SetCameraResolution(float newValue) {
if (newValue < 0.0) {
throw "Camera resolution cannot be negative!";
}
cameraResolution = newValue;
}
};
|