/*****************************************************************/ /* Copyright 2013 Code Strategies */ /* This code may be freely used and distributed in any project. */ /* However, please do not remove this credit if you publish this */ /* code in paper or electronic form, such as on a web site. */ /*****************************************************************/ package com.cakes; // Context public class Person implements EmotionalState { EmotionalState emotionalState; public Person(EmotionalState emotionalState) { this.emotionalState = emotionalState; } public void setEmotionalState(EmotionalState emotionalState) { this.emotionalState = emotionalState; } @Override public String sayGoodbye() { return emotionalState.sayGoodbye(); } @Override public String sayHello() { return emotionalState.sayHello(); } }