Example #1
0
        public override void PrintDocument(PrinterContext context)
        {
            Console.WriteLine($"Printed the document {context.Document}");
            context.Money--;

            if (context.Money > 0)
            {
                context.State = new ChooseDocumentState();
            }
            else
            {
                context.State = new PayState();
            }
        }
Example #2
0
 public virtual void ChooseDocument(PrinterContext context)
 {
     throw new NotImplementedException();
 }
Example #3
0
 public virtual void Pay(PrinterContext context)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public override void GetCash(PrinterContext context)
 {
     throw new Exception("Interaction is stopped");
 }
Example #5
0
 public override void PrintDocument(PrinterContext context)
 {
     throw new Exception("Interaction is stopped");
 }
Example #6
0
 public override void ChooseDevice(PrinterContext context)
 {
     throw new Exception("Interaction is stopped");
 }
Example #7
0
 public override void GetCash(PrinterContext context)
 {
     context.Money = 0;
     context.State = new StoppedState();
 }
Example #8
0
 public override void Stop(PrinterContext context)
 {
     context.State = new GetCashState();
 }
Example #9
0
 public override void ChooseDocument(PrinterContext context)
 {
     Console.WriteLine($"Chose the document {context.Document}");
     context.State = new PrintDocumentState();
 }
Example #10
0
 public override void ChooseDevice(PrinterContext context)
 {
     Console.WriteLine($"Chose the device type {context.DeviceType}");
     context.State = new ChooseDocumentState();
 }
Example #11
0
 public override void Pay(PrinterContext context)
 {
     Console.WriteLine($"Payed the money {context.State}");
     context.State = new ChooseDeviceState();
 }
Example #12
0
 public override void Start(PrinterContext context)
 {
     context.State = new PayState();
 }
Example #13
0
 public virtual void Stop(PrinterContext context)
 {
     context.State = new StoppedState();
 }