//Basic function for compiling messages to send to console, // need virtual keyword for polymorphism public virtual void Respond(InterfaceHandler _interface) { List <string> message = new List <string> { ReplyMessage, FarewellMessage }; _interface.WriteTo(message); _interface.Exit(); }
public void TellJoke(Random _rand, InterfaceHandler _interface) { char input = _interface.GetResponse(); if (input == 'Y' || input == 'y') { List <string> Joke = GetJoke(_rand); Joke.Add("Would you like to hear another joke?"); _interface.WriteTo(Joke); TellJoke(_rand, _interface); } }
static void Main(string[] args) { var Interface = new InterfaceHandler(); //Greet user Interface.Greeting(); //Get response from user char response = Interface.GetResponse(); //Respond to user, can use any subclass of Feeling var Handler = new ResponseHandler(response); Feeling Today = Handler.Today; Today.Respond(Interface); }
public override void Respond(InterfaceHandler _interface) { List <string> First = new List <string> { ReplyMessage, "Would a joke cheer you up?", "Press Y for Yes and N for No" }; _interface.WriteTo(First); Random rand = new Random(); TellJoke(rand, _interface); List <string> Final = new List <string> { "That's a no to a joke.", FarewellMessage }; _interface.WriteTo(Final); _interface.Exit(); }