Design/strategy/main.cpp

19 lines
420 B
C++
Raw Normal View History

2024-10-28 14:07:29 +08:00
/*
* @Description:
* @version:
* @Author:
* @Date: 2023-10-26 11:12:18
* @LastEditors:
* @LastEditTime: 2023-10-26 11:13:43
*/
#include "Strategy.hpp"
int main() {
// 使用
Farm* farm = new Farm();
farm->setStrategy(new WheatPlantStrategy());
farm->plantCrop(); // 调用小麦栽种逻辑
farm->setStrategy(new RicePlantStrategy());
farm->plantCrop(); // 调用稻米栽种逻辑
}