Skip to content

Instantly share code, notes, and snippets.

@Naphier
Created December 30, 2015 18:14
Show Gist options
  • Save Naphier/184ea641245378a8efb3 to your computer and use it in GitHub Desktop.
Save Naphier/184ea641245378a8efb3 to your computer and use it in GitHub Desktop.
Strategy Pattern Example - String Output
public class OutputStrategyController : MonoBehaviour
{
public string input = "This is some arbitrary input string";
void Start()
{
OutputContext context = new OutputContext(new CSVOutput(' '));
Debug.Log("This is the CSV output:\n" + context.GetOutput(input));
//Easily change the context!
context = new OutputContext(new EncryptedOutput());
Debug.Log("This is the encrypted output:\n" + context.GetOutput(input));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment