-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsoil.h
56 lines (44 loc) · 1.32 KB
/
soil.h
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
#include"weather.h"
class Soil {
protected:
float humidity = 0; //土壤湿度
float temperature = 0; //土壤温度
float fertility = 0; //土壤肥力
float pesticideResidue = 0; //农药残留
int id; //土壤的id
virtual void weather(const class Weather& weather) = 0; //根据天气修改土壤的相关数据
virtual void applyFertilizer(int Fertilize) = 0; //施用化肥
virtual void applyPesticide(int Pesticide) = 0; //喷农药
virtual void irrigate(int water) = 0; //灌溉
virtual void mulch(int time) = 0; //覆盖地膜
public:
Soil();
virtual ~Soil() = default;
//获取相关变量的值
float getHumidity() const {
return humidity;
}
float getTemperature() const {
return temperature;
}
float getFertility() const {
return fertility;
}
float getPesticideResidue() const {
return pesticideResidue;
}
int getId() const {
return id;
}
};
//具体派生类
class ClaySoil : public Soil {
public:
ClaySoil() {}
~ClaySoil() override {}
void weather(const Weather& weather);
void applyFertilizer(int Fertilize);
void applyPesticide(int Pesticide);
void irrigate(int water);
void mulch(int time);
};