Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CodeKata
- {
- public class Kata
- {
- private readonly Status _status;
- public Kata(Status status)
- {
- _status = status;
- }
- public Kata()
- {
- }
- public string GetStatusDescription()
- {
- if(_status == null)
- {
- return "I have never been set";
- }
- else {
- return _status.GetStatusDescription();
- }
- }
- }
- public abstract class Status
- {
- public abstract string GetStatusDescription();
- }
- public class NewStatus : Status
- {
- public override string GetStatusDescription()
- {
- return "I am new!";
- }
- }
- public class ActiveStatus : Status
- {
- public override string GetStatusDescription()
- {
- return "I am active";
- }
- }
- public class DeactivatedStatus : Status
- {
- public override string GetStatusDescription()
- {
- return "I have been deactivated";
- }
- }
- public class ExampleTestCases
- {
- static void Main(string[] args) {
- string status;
- status = new Kata().GetStatusDescription();
- Console.WriteLine(status);
- status = new Kata(new NewStatus()).GetStatusDescription();
- Console.WriteLine(status);
- status = new Kata(new ActiveStatus()).GetStatusDescription();
- Console.WriteLine(status);
- status = new Kata(new DeactivatedStatus()).GetStatusDescription();
- Console.WriteLine(status);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement