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 57 58 59 60 61 62 63 64 65 66 67 68
| #include <iostream> #include "State.h" #pragma once #include "Sanji.h" using namespace std;
void ForenoonState::working(Sanji* sanji) { int time = sanji->getClock(); if (time < 8) { cout << "当前时间<" << time << ">点, 准备早餐, 布鲁克得多喝点牛奶..." << endl; } else if (time > 8 && time < 11) { cout << "当前时间<" << time << ">点, 去船头钓鱼, 储备食材..." << endl; } else { sanji->setState(new NoonState); sanji->working(); } }
void NoonState::working(Sanji* sanji) { int time = sanji->getClock(); if (time < 13) { cout << "当前时间<" << time << ">点, 去厨房做午饭, 给路飞多做点肉..." << endl; } else { sanji->setState(new AfternoonState); sanji->working(); } }
void AfternoonState::working(Sanji* sanji) { int time = sanji->getClock(); if (time < 15) { cout << "当前时间<" << time << ">点, 准备下午茶, 给罗宾和娜美制作爱心甜点..." << endl; } else if (time > 15 && time < 18) { cout << "当前时间<" << time << ">点, 和乔巴去船尾钓鱼, 储备食材..." << endl; } else { sanji->setState(new EveningState); sanji->working(); } }
void EveningState::working(Sanji* sanji) { int time = sanji->getClock(); if (time < 19) { cout << "当前时间<" << time << ">点, 去厨房做晚饭, 让索隆多喝点汤..." << endl; } else { cout << "当前时间<" << time << ">点, 今天过得很高兴, 累了睡觉了..." << endl; } }
|