Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************************************************************************/
- // Task 13.2a: Complete this class so that it correctly returns
- // Checks if the moon is closer or further away from the specified distance
- /************************************************************************/
- class MoonCondition : public Condition {
- public:
- State state;
- /**
- * Performs the test for this condition.
- */
- virtual bool test() {
- if (state == Wandering && moon->Position.distance(earth->Position) < 1) {
- return true;
- }
- if (state == Following && moon->Position.distance(earth->Position) > 1) {
- return true;
- }
- return false;
- }
- };
- /************************************************************************/
- // Task 13.2b: After you have completed the MoonCondition object, instantiate it here
- /************************************************************************/
- MoonCondition* ShouldFollow = new MoonCondition();
- ShouldFollow->state = Wandering;
- // This condition should trigger if the moon is closer than 1 unit to the Earth
- MoonCondition* ShouldWander = new MoonCondition();
- ShouldWander->state = Following;
- // This condition should trigger if the moon is further away than 1 unit from the Earth
Advertisement
Add Comment
Please, Sign In to add comment