-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesting.cpp
More file actions
47 lines (41 loc) · 1.32 KB
/
Testing.cpp
File metadata and controls
47 lines (41 loc) · 1.32 KB
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
// TestMain.cpp
#include <iostream>
#include "Plant.h"
#include "Seedling.h"
#include "Growing.h"
#include "Mature.h"
#include "Withered.h"
// Simple concrete plant just for testing
class DemoPlant : public Plant {
public:
DemoPlant(const std::string& name, const std::string& type)
: Plant(name, type) {}
// Plant* clone() override { return new DemoPlant(*this); }
};
int main() {
DemoPlant p("Rosemary", "Herb");
// Start as Seedling
p.initState(new Seedling());
std::cout << p.getName() << " initial state: " << p.getStateName() << "\n";
// Simulate 25 days; water every 3rd day
for (int day = 1; day <= 25; ++day) {
std::cout << "\n-- Day " << day << " --\n";
if (day % 3 == 0) {
std::cout << "Action: watering\n";
p.water();
}
p.dailyTick();
std::cout << "Now in state: " << p.getStateName()
<< " | ageDays=" << p.getAgeDays()
<< " | hydration=" << p.getHydrationLevel() << "\n";
if (p.getStateName() == "Mature" && day == 23) {
std::cout << "Action: harvest\n";
p.harvestAndStore();
}
}
// Force discard
std::cout << "\nAction: discard" << std::endl;
p.discard();
std::cout << "Final state: " << p.getStateName() << "\n";
return 0;
}