public override int GetChange(PrintMachine machine) { var deposit = machine.Deposit; machine.State = new InitState(); machine.Deposit = 0; machine.Type = DeviceTypes.None; return(deposit); }
public override void Print(PrintMachine machine) { if (machine.Deposit - machine.Cost < 0) { Console.WriteLine("Money not enough =("); machine.State = machine.Deposit > 0 ? (StateBase) new GetShortChangeState() : new InitState(); return; } Console.WriteLine($"The document '{machine.Filename}' was printed"); machine.Deposit -= machine.Cost; machine.State = new ContinueOrChangeState(); }
public override void SetDevice(DeviceTypes type, PrintMachine machine) { throw new Exception("The change must be taken"); }
public override void SetDocument(string filename, PrintMachine machine) { throw new Exception("The document was setted"); }
public override int GetChange(PrintMachine machine) { var getChangeState = new GetShortChangeState(); return(getChangeState.GetChange(machine)); }
public override int GetChange(PrintMachine machine) { throw new Exception("PrintMachine wants document selection"); }
public override void SetDocument(string filename, PrintMachine machine) { machine.Filename = filename; machine.State = new PrintState(); }
public override void SetDocument(string filename, PrintMachine machine) { throw new Exception("PrintMachine wants device selection"); }
public abstract void Print(PrintMachine machine);
public override void SetMoney(int count, PrintMachine machine) { machine.Deposit = count; machine.State = new DeviceSelectionState(); }
public override void SetDevice(DeviceTypes type, PrintMachine machine) { machine.Type = type; machine.State = new DocumentSelectionState(); }
public override int GetChange(PrintMachine machine) { throw new Exception("PrintMachine wants money"); }
public override void Print(PrintMachine machine) { throw new Exception("PrintMachine wants money"); }
public override void SetDevice(DeviceTypes type, PrintMachine machine) { throw new Exception("PrintMachine wants money"); }
public override void SetDocument(string filename, PrintMachine machine) { throw new Exception("The change must be taken"); }
public abstract int GetChange(PrintMachine machine);
public override void Print(PrintMachine machine) { throw new Exception("The change must be taken"); }
public abstract void SetMoney(int count, PrintMachine machine);
public override void SetDevice(DeviceTypes type, PrintMachine machine) { throw new Exception("The device was setted"); }
public abstract void SetDevice(DeviceTypes type, PrintMachine machine);
public override void Print(PrintMachine machine) { throw new Exception("PrintMachine wants document selection"); }
public abstract void SetDocument(string filename, PrintMachine machine);
public override void SetMoney(int count, PrintMachine machine) { }
public override void SetDocument(string filename, PrintMachine machine) { var docSelectState = new DocumentSelectionState(); docSelectState.SetDocument(filename, machine); }