Пример #1
0
 //TV is On now, user is pressing Mute button
 public void PressMuteButton(TV context)
 {
     Console.WriteLine("TV was on.So,moving to silent mode.");
     context.CurrentState = new Mute();
 }
Пример #2
0
 //Users can press any of these buttons at this state-On, Off or Mute
 //TV is in mute, user is pressing On button
 public void PressOnButton(TV context)
 {
     Console.WriteLine("TV was in mute mode.So, moving to normal state.");
     context.CurrentState = new On();
 }
Пример #3
0
 //TV is Off now, user is pressing Mute button
 public void PressMuteButton(TV context)
 {
     Console.WriteLine("TV was already off.So, ignoring this operation.");
 }
Пример #4
0
 //Users can press any of these buttons at this state-On, Off or Mute
 //TV is On already, user is pressing On button again
 public void PressOnButton(TV context)
 {
     Console.WriteLine("TV is already in On state.Ignoring repeated on button press operation.");
 }
Пример #5
0
 //TV is Off now, user is pressing On button
 public void PressOnButton(TV context)
 {
     Console.WriteLine("TV was Off.Going from Off to On state.");
     context.CurrentState = new On();
 }
Пример #6
0
 //TV is Off already, user is pressing Off button again
 public void PressOffButton(TV context)
 {
     Console.WriteLine("TV was already in Off state.So, ignoring this opeation.");
 }
 //Users can press any of these buttons at this state-On, Off or Mute
 //TV is in mute, user is pressing On button
 public void PressOnButton(TV context)
 {
     Console.WriteLine("You pressed On button.Going from Mute mode to On state.");
     tvContext.CurrentState = new On(context);
 }
 //TV is Off already, user is pressing Off button again
 public void PressOffButton(TV context)
 {
     Console.WriteLine(" You pressed Off button. TV is already in Off state");
 }
 //TV is On now, user is pressing Mute button
 public void PressMuteButton(TV context)
 {
     Console.WriteLine("You pressed Mute button.Going from On to Mute mode.");
     tvContext.CurrentState = new Mute(context);
 }
 public Mute(TV context)
 {
     Console.WriteLine(" TV is in Mute mode now.");
     this.tvContext = context;
 }
 //Users can press any of these buttons at this state-On, Off or Mute
 //TV is On already, user is pressing On button again
 public void PressOnButton(TV context)
 {
     Console.WriteLine("You pressed On button. TV is already in On state.");
 }
 public On(TV context)
 {
     Console.WriteLine(" TV is On now.");
     this.tvContext = context;
 }
 //TV is Off now, user is pressing Mute button
 public void PressMuteButton(TV context)
 {
     Console.WriteLine(" You pressed Mute button.TV is already in Off state, so Mute operation will not work.");
 }
Пример #14
0
 //TV is in mute, user is pressing Off button
 public void PressOffButton(TV context)
 {
     Console.WriteLine("TV was in mute mode. So, switching off the TV.");
     context.CurrentState = new Off();
 }
 //TV is in mute, user is pressing Off button
 public void PressOffButton(TV context)
 //public void PressOffButton()
 {
     Console.WriteLine("You pressed Off button. Going to Mute mode to Off state.");
     tvContext.CurrentState = new Off(context);
 }
Пример #16
0
 //TV is in mute already, user is pressing mute button again
 public void PressMuteButton(TV context)
 {
     Console.WriteLine(" TV is already in Mute mode, so, ignoring this operation.");
 }
 //TV is in mute already, user is pressing mute button again
 public void PressMuteButton(TV context)
 {
     Console.WriteLine(" You pressed Mute button.TV is already in Mute mode.");
 }