Exemple #1
0
 public Medium(int currentTemp, Steak steak)
 {
     this.CurrentTemp = currentTemp;
     this.Steak       = steak;
     CanEat           = true;
     Initialize();
 }
 public Rare(double currentTemp, Steak steak)
 {
     this.currentTemp = currentTemp;
     this.steak       = steak;
     canEat           = true; //We can now eat the steak
     Initialize();
 }
Exemple #3
0
 public Done(int currentTemp, Steak steak)
 {
     this.CurrentTemp = currentTemp;
     this.Steak       = steak;
     CanEat           = false;
     Initialize();
 }
 public WellDone(double currentTemp, Steak steak)
 {
     this.currentTemp = currentTemp;
     this.steak       = steak;
     canEat           = true;
     Initialize();
 }
 public Rare(double currentTemp, Steak steak)
 {
     this.currentTemp = currentTemp;
     this.steak       = steak;
     Initialize();
     DonenessCheck();
 }
 public MediumRare(double currentTemp, Steak steak)
 {
     this.currentTemp = currentTemp;
     this.steak       = steak;
     canEat           = true;
     Initialize();
 }
 public Burned(double currentTemp, Steak steak)
 {
     this.currentTemp = currentTemp;
     this.steak       = steak;
     this.Initialize();
     this.canEat = false;
     DonenessCheck();
 }
 public Ruined(double currentTemp, Steak steak)
 {
     this.currentTemp = currentTemp;
     this.steak       = steak;
     canEat           = true;
     Initialize();
     DonenessCheck();
 }
        public void SteakBurnedCantEat()
        {
            // arrange
            var steak = new Steak("ex-Cow");

            // act
            // assert
            Assert.Throws <Exception>(() => steak.AddTemp(5000));
        }
        public Client()
        {
            //Let's cook a steak!
            Steak account = new Steak("T-Bone");

            // Apply temperature changes
            account.AddTemp(120);
            account.AddTemp(15);
            account.AddTemp(15);
            account.RemoveTemp(10); //Yes I know cooking doesn't work this way, bear with me.
            account.RemoveTemp(15);
            account.AddTemp(20);
            account.AddTemp(20);
            account.AddTemp(20);

            //Console.ReadKey();
        }
Exemple #11
0
        /// <summary>
        /// The State pattern encapsulates states of an object as objects themselves, and uses a Context class
        /// (the Steak class in this example) to store the current state of the object and the object itself.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Let's cook a steak!
            Steak steak = new Steak("T-Bone");

            // Apply temperature changes
            steak.AddTemp(120);
            steak.AddTemp(15);
            steak.AddTemp(15);
            steak.RemoveTemp(10); //Yes I know cooking doesn't work this way, bear with me.
            steak.RemoveTemp(15);
            steak.AddTemp(20);
            steak.AddTemp(20);
            steak.AddTemp(20);

            Console.ReadKey();
        }
        public void CookSteak_With_Design()
        {
            //Let's cook a steak!
            Steak account = new Steak("T-Bone");

            // Apply temperature changes
            account.AddTemp(120);
            account.AddTemp(15);
            account.AddTemp(15);
            account.RemoveTemp(10);  //Yes I know cooking doesn't work this way
            account.RemoveTemp(15);
            account.AddTemp(20);
            account.AddTemp(20);
            account.AddTemp(20);

            Assert.True(account.State.CanEat);
        }