public void ObtenerMejorOpcion_EnviarCostoDeEnvioAlto_MensajeConDiferenciaDePrecio() { //Arrange string cResultado = ""; lEnvios aereo = new Avion() { dVelocidadEntrega = 600, dCostoEnvio = 10, cNombre = "Avion" }; lEnvios barco = new Barco() { dVelocidadEntrega = 46, dCostoEnvio = 1, cNombre = "Barco" }; lEmpresas fedex = new Estafeta(new List <lEnvios>() { barco }, 50, "Fedex"); lEmpresas dhl = new DHL(new List <lEnvios>() { aereo, barco }, 40, "DHL"); List <lEmpresas> lstEmpresas = new List <lEmpresas>() { fedex, dhl }; BuscarMejorOpcion buscarMejorOpcion = new BuscarMejorOpcion(); DateTime dtHoy = Convert.ToDateTime("27-01-2020 12:00:00"); DateTime dtEntrega = Convert.ToDateTime("28-01-2020 12:00:00"); State.State entPedido = new State.State(new DesactivarState(), "México", "USA", 2500, fedex, barco, dtHoy); //Act cResultado = buscarMejorOpcion.ObtenerMejorOpcion(lstEmpresas, dhl, entPedido, 5000); //Assert Assert.AreEqual("Si hubieras pedido en Fedex te hubiera costado 1250.0 mas barato", cResultado); }
// El constructor inserta el combustible del que dispondra el vehiculo public Vehiculo(int combustible) { this.combustibleActual = combustible; //TODO: //Indicar un estado inicial (Apagado) estado = new ApagadoState(this); }
public Context(string owner ,double init) { this.owner = owner; this.balance = init; this.state = new NormalState(this); Console.WriteLine(this.owner+"KH,Account:"+init); Console.WriteLine("-------------------------------------------------"); }
public static List<State> GeneratePlay (State cur) { List<State> result = new List<State>(); while (cur != null) { result.Add(cur); cur = cur.parent; } result.Reverse(); return result; }
public decimal TiempoTraslado(State.State _entPedido) { lPresentadorTexto presentadorTexto = new PresentadorTexto(); decimal TiempoTraslado = 0; if (lstEnvios.Contains(_entPedido.cMedioTransporte)) { TiempoTraslado = _entPedido.dDistancia / _entPedido.cMedioTransporte.dVelocidadEntrega; } return(TiempoTraslado); }
public void setStrategy_EnviarEstrategia_ContextoDiferenteDeNull() { //Arrange lEnvios barco = new Maritimo() { dVelocidadEntrega = 46, dCostoEnvio = 1 }; lEmpresas fedex = new Estafeta(new List<lEnvios>() { barco }, 50, "Fedex"); DateTime dtHoy = Convert.ToDateTime("27-01-2020 12:00:00"); DateTime dtEntrega = Convert.ToDateTime("28-01-2020 12:00:00"); //Act State.State entPedido = new State.State(new DesactivarState(), "México", "USA", 5000, fedex, barco, dtHoy); //Assert Assert.IsNotNull(entPedido); }
public bool Commit () { Array.Sort(m_Items, 0, m_Count, m_Comparer); m_First = m_Items[0]; m_Items[0] = null; if (m_Count > m_Size) { m_TotalDiscarded += m_Count - m_Size; m_Count = m_Size; } while (m_Count > 0 && m_Items[m_Count - 1] == null) { --m_Count; } return m_First != null; }
public decimal TiempoTraslado(State.State _entPedido) { decimal TiempoTraslado = 0; if (lstEnvios.Contains(_entPedido.cMedioTransporte)) { TiempoTraslado = _entPedido.dDistancia / _entPedido.cMedioTransporte.dVelocidadEntrega; } else { System.Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"DHL no ofrece el servicio de transporte {_entPedido.cMedioTransporte.cNombre}, te recomendamos cotizaren otra empresa."); } return(TiempoTraslado); }
private void Calculate (List<NodeCollection> node_collections, State cur, ICostFactory cost_factory, OnProgressDelegate on_progress, OnProgressArg on_progress_arg, ref State best) { on_progress_arg.progress_cur = (int)( ( (float)(cur.distance_from_start + 1) / (float)(on_progress_arg.depth_max) ) * 100.0f ); on_progress(on_progress_arg); if (cur.distance_from_start == node_collections.Count - 1) { //This is a completed play if (best == null) { best = cur; } else if (cur.cost.GetTotalCost() < best.cost.GetTotalCost()) { best = cur; } return; } if (!on_progress_arg.carry_on) { return; } int index = cur.distance_from_start + 1; NodeCollection collection = node_collections[index]; Beat beat = collection.beat; List<State> nxt_list = new List<State>(); foreach (Node node in collection.items) { List<Analyzer.State.Limb[]> neighbours = new List<Analyzer.State.Limb[]>(); ArcCalculator.Calculate(cur, node, neighbours); foreach (Analyzer.State.Limb[] n in neighbours) { State nxt = ArcCalculator.TransitionTo(cur, n, collection.beat.second, index, beat, cost_factory); if (nxt == null) { continue; } if (best == null || nxt.cost.GetTotalCost() < best.cost.GetTotalCost()) { nxt_list.Add(nxt); } } } nxt_list.Sort((State a, State b) => { return a.cost.GetTotalCost().CompareTo(b.cost.GetTotalCost()); }); foreach (State n in nxt_list) { Calculate(node_collections, n, cost_factory, on_progress, on_progress_arg, ref best); } }
void Start() { /* * this.state = new State.ChainedState(new State.State[] { * new State.TimedState("A", 120), * new State.TimedState("B", 200), * new State.TimedState("C", 100).Resets() * }); */ this.state = new State.ChainedState(new State.State[] { new State.TimedState("A", 60), new State.TimedState("B", 200), }).Loops(); this.timer = new Timer.Timer(); }
public void FechaEntrega_EnviarTiempoTrasladoMayorACero_FechaDeEntregaDiferenteAFechaHoy() { //Arrange DateTime dtResultado = new DateTime(); lEnvios barco = new Barco() { dVelocidadEntrega = 46, dCostoEnvio = 1 }; lEmpresas estafeta = new Estafeta(new List <lEnvios>() { barco }, 50, "Estafeta"); DateTime dtHoy = Convert.ToDateTime("27-01-2020 12:00:00"); State.State entPedido = new State.State(new DesactivarState(), "México", "USA", 2500, estafeta, barco, dtHoy); //Act dtResultado = estafeta.FechaEntrega(54, entPedido); //Assert Assert.AreNotEqual(dtResultado, dtHoy); }
public void FechaEntrega_EnviarTiempoTrasladoMayorACero_FechaDeEntregaMenorAFechaHoy() { //Arrange DateTime dtResultado = new DateTime(); lEnvios barco = new Maritimo() { dVelocidadEntrega = 46, dCostoEnvio = 1 }; lEmpresas dhl = new DHL(new List <lEnvios>() { barco }, 50, "Fedex"); DateTime dtHoy = Convert.ToDateTime("27-01-2020 12:00:00"); State.State entPedido = new State.State(new DesactivarState(), "México", "USA", 2500, dhl, barco, dtHoy); //Act dtResultado = dhl.FechaEntrega(-10, entPedido); //Assert Assert.IsTrue(dtResultado < dtHoy); }
public void TiempoTraslado_EnviarListaTransportesVacia_TiempoTrasladoCero() { //Arrange decimal iResultado = 0; lEnvios barco = new Maritimo() { dVelocidadEntrega = 46, dCostoEnvio = 1 }; lEmpresas dhl = new DHL(new List <lEnvios>() { }, 50, "Fedex"); DateTime dtHoy = Convert.ToDateTime("27-01-2020 12:00:00"); DateTime dtEntrega = Convert.ToDateTime("28-01-2020 12:00:00"); State.State entPedido = new State.State(new DesactivarState(), "México", "USA", 2500, dhl, barco, dtHoy); //Act iResultado = dhl.TiempoTraslado(entPedido); //Assert Assert.IsTrue(iResultado == 0); }
public void TiempoTraslado_EnviarFechaDeEntregaMayorAHoy_ValorDiferenteDeCero() { //Arrange decimal iResultado = 0; lEnvios barco = new Barco() { dVelocidadEntrega = 46, dCostoEnvio = 1 }; lEmpresas estafeta = new Estafeta(new List <lEnvios>() { barco }, 50, "Estafeta"); DateTime dtHoy = Convert.ToDateTime("27-01-2020 12:00:00"); DateTime dtEntrega = Convert.ToDateTime("28-01-2020 12:00:00"); State.State entPedido = new State.State(new DesactivarState(), "México", "USA", 2500, estafeta, barco, dtHoy); //Act iResultado = estafeta.TiempoTraslado(entPedido); //Assert Assert.IsTrue(iResultado != 0); }
public void CostoEnvio_EviarDistanciaMayorACincuenta_CostoEnvioMayorACero() { //Arrange decimal dResultado = 0; decimal dEsperado = 3750; lEnvios barco = new Barco() { dVelocidadEntrega = 46, dCostoEnvio = 1 }; lEmpresas estafeta = new Estafeta(new List <lEnvios>() { barco }, 50, "Estafeta"); DateTime dtHoy = Convert.ToDateTime("27-01-2020 12:00:00"); State.State entPedido = new State.State(new DesactivarState(), "México", "USA", 2500, estafeta, barco, dtHoy); //Act dResultado = estafeta.CostoEnvio(entPedido); //Assert Assert.AreEqual(dEsperado, dResultado); }
public void Ejecutar_EnviarFechaEntregaMenorAHoy_TextoEntregado() { //Arrange string cResultado = ""; Expresion2 expresion2 = new Expresion2(); lEnvios barco = new Maritimo() { dVelocidadEntrega = 46, dCostoEnvio = 1 }; lEmpresas fedex = new Estafeta(new List <lEnvios>() { barco }, 50, "Fedex"); DateTime dtHoy = Convert.ToDateTime("29-01-2020 12:00:00"); DateTime dtEntrega = Convert.ToDateTime("28-01-2020 12:00:00"); State.State entPedido = new State.State(new DesactivarState(), "México", "USA", 5000, fedex, barco, Convert.ToDateTime("27-01-2020 12:00:00")); //Act cResultado = expresion2.Ejecutar(dtEntrega, dtHoy, entPedido); //Assert Assert.AreEqual("llegó", cResultado); }
public void Ejecutar_EnviarFechaEntregaMayorMesAFechaHoy_MesRestantes() { //Arrange string cResultado = ""; Expresion5 expresion5 = new Expresion5(); lEnvios barco = new Barco() { dVelocidadEntrega = 46, dCostoEnvio = 1 }; lEmpresas fedex = new Estafeta(new List <lEnvios>() { barco }, 50, "Fedex"); DateTime dtHoy = Convert.ToDateTime("27-01-2020 12:00:00"); DateTime dtEntrega = Convert.ToDateTime("27-02-2020 12:00:00"); State.State entPedido = new State.State(new DesactivarState(), "México", "USA", 150000, fedex, barco, dtHoy); //Act cResultado = expresion5.Ejecutar(dtEntrega, dtHoy, entPedido); //Assert Assert.AreEqual("1 Meses", cResultado); }
public void Ejecutar_EnviarFechaEntregaMayorSemanasAFechaHoy_SemanasFaltantes() { //Arrange string cResultado = ""; Expresion5 expresion5 = new Expresion5(); lEnvios Aereo = new Aereo() { dVelocidadEntrega = 800, dCostoEnvio = 1 }; lEmpresas dhl = new DHL(new List <lEnvios>() { Aereo }, 10, "DHL"); DateTime dtHoy = Convert.ToDateTime("15-02-2020 08:00:00"); DateTime dtEntrega = Convert.ToDateTime("06-03-2020 12:00:00"); State.State entPedido = new State.State(new DesactivarState(), "China", "Cancún", 446400, dhl, Aereo, dtHoy); //Act cResultado = expresion5.Ejecutar(dtEntrega, dtHoy, entPedido); //Assert Assert.AreEqual("3 Semanas", cResultado); }
// Constructor public Account(string owner) { // New accounts are 'Silver' by default this._owner = owner; this._state = new SilverState(0.0, this); }
static void Main(string[] args) { lBuscarMejorOpcion buscarMejorOpcion = new BuscarMejorOpcion(); lAsignarDatosEnvio lasignarDatosEnvio = new AsignarDatosEnvio(); Context context = new Context(); lConvertirTipoDato convertirTipoDato = new CovertirTipoDatoService(); double dTiempoTraslado = 0; decimal TiempoTraslado = 0; decimal dCostoEnvio = 0; string cExpresion1 = ""; string cExpresion2 = ""; string cExpresion3 = ""; string cExpresion4 = ""; string cExpresion5 = ""; DateTime dtFechaEntrega = new DateTime(); DateTime dtHoy = DateTime.Now; lLeerArchivoTexto Lector = new LeerArchivoTexto(); lEmpresas empresa = null; lEnvios transporte = null; lEnvios aereo = new Avion() { dVelocidadEntrega = 600, dCostoEnvio = 10, cNombre = "Avion" }; lEnvios tren = new Tren() { dVelocidadEntrega = 80, dCostoEnvio = 5, cNombre = "Tren" }; lEnvios barco = new Barco() { dVelocidadEntrega = 46, dCostoEnvio = 1, cNombre = "Barco" }; lEnvios bici = new Bici() { dVelocidadEntrega = 1, dCostoEnvio = 3, cNombre = "Bici" }; lEmpresas fedex = new Estafeta(new List <lEnvios>() { barco }, 50, "Fedex"); lEmpresas dhl = new DHL(new List <lEnvios>() { aereo, barco }, 40, "DHL"); lEmpresas estafeta = new Estafeta(new List <lEnvios>() { tren }, 20, "Estafeta"); lEmpresas upc = new UPC(new List <lEnvios>() { bici }, 50, "UPC"); List <lEmpresas> lstEmpresas = new List <lEmpresas>() { fedex, dhl, estafeta, upc }; List <lEnvios> lstTransportes = new List <lEnvios>() { aereo, tren, barco, bici }; List <string> lines = Lector.LeerArchivo("Pedidos.txt"); foreach (string line in lines) { string[] cInformacion = line.Split(','); lasignarDatosEnvio.AsignarEmpresa(cInformacion[3], ref empresa, lstEmpresas); lasignarDatosEnvio.AsignarTransporte(cInformacion[4], ref transporte, lstTransportes); if (empresa != null) { Pedido initialState = new DesactivarState(); State.State entPedido = new State.State(initialState, cInformacion[0], cInformacion[1], convertirTipoDato.ConvertirStringADecimal(cInformacion[2]), empresa, transporte, Convert.ToDateTime(cInformacion[5])); initialState.setContext(entPedido); TiempoTraslado = empresa.TiempoTraslado(entPedido); if (TiempoTraslado > 0) { dTiempoTraslado = convertirTipoDato.ConvertirDecimalADouble(TiempoTraslado); dtFechaEntrega = empresa.FechaEntrega(dTiempoTraslado, entPedido); dCostoEnvio = empresa.CostoEnvio(entPedido); Console.WriteLine(buscarMejorOpcion.ObtenerMejorOpcion(lstEmpresas, empresa, entPedido, dCostoEnvio)); Expresion1 expresion1 = new Expresion1(); context.setStrategy(expresion1); cExpresion1 = context.ValidarFechaEntrega(dtFechaEntrega, dtHoy, entPedido); Expresion2 expresion2 = new Expresion2(); context.setStrategy(expresion2); cExpresion2 = context.ValidarFechaEntrega(dtFechaEntrega, dtHoy, entPedido); Expresion3 expresion3 = new Expresion3(); context.setStrategy(expresion3); cExpresion3 = context.ValidarFechaEntrega(dtFechaEntrega, dtHoy, entPedido); Expresion4 expresion4 = new Expresion4(); context.setStrategy(expresion4); cExpresion4 = context.ValidarFechaEntrega(dtFechaEntrega, dtHoy, entPedido); Expresion5 expresion5 = new Expresion5(); context.setStrategy(expresion5); cExpresion5 = context.ValidarFechaEntrega(dtFechaEntrega, dtHoy, entPedido); if (entPedido.state.ToString() == "State.ActivarState") { System.Console.ForegroundColor = ConsoleColor.Green; } else { System.Console.ForegroundColor = ConsoleColor.Yellow; } Console.WriteLine($"Tu paquete {cExpresion1} de {entPedido.cOrigen} y {cExpresion2} a {entPedido.cDestino} {cExpresion3} {cExpresion5} y {cExpresion4} un costo de {dCostoEnvio} (Cualquier reclamación con {cInformacion[3]})."); } } Console.WriteLine(); } Console.ReadLine(); }
// Overloaded constructors public StandardState(State state) { this.nextPage = "Main Page"; this.user = state.User; Initialize(); }
public decimal CostoEnvio(State.State _entPedido) { decimal dCosto = (_entPedido.cMedioTransporte.dCostoEnvio * _entPedido.dDistancia) * (1 + (_entPedido.cPaqueteria.MargenUtilidad / 100)); return(dCosto); }
public static State Calculate ( State initial, List<NodeCollection> path, int storage_limit, ICostFactory cost_factory, OnProgressDelegate on_progress, OnProgressArg arg ) { int path_offset = initial.distance_from_start + 1; OpenedStateCollection opened = new OpenedStateCollection(storage_limit, 1000/*magic number*/, new StateComparer(0.2f/*magic number*/)); opened.Add(initial); State prv_opened = null; State result = null; List<State> tmp = new List<State>(); while (opened.Commit()) { State cur = opened.First(); int nxt_distance_from_start = cur.distance_from_start + 1; int path_index = nxt_distance_from_start - path_offset; if (path_index == path.Count) { if (result == null || result.cost.GetTotalCost() > cur.cost.GetTotalCost()) { result = cur; } continue; } prv_opened = cur; Beat beat = path[path_index].beat; List<Node> neighbours = path[path_index].items; if (on_progress != null) { arg.progress_cur = (int)((float)nxt_distance_from_start / (float)arg.depth_max * 100.0f); arg.depth_cur = nxt_distance_from_start; arg.second_cur = cur.second; ++arg.closed; arg.opened_cur = opened.Count(); arg.opened_total = arg.prv_iter_opened_total + opened.GetTotalAdded(); arg.discarded = arg.prv_iter_discarded + opened.GetTotalDiscarded(); on_progress(arg); if (!arg.carry_on) { return result; } } if (neighbours.Count == 0) { throw new ExecutionEngineException(); } else { //tmp.Clear(); foreach (Node n in neighbours) { if (!ArcCalculator.IsArcValid(cur, n)) { continue; } List<Analyzer.State.Limb[]> possibilities = new List<Analyzer.State.Limb[]>(); ArcCalculator.Calculate(cur, n, possibilities); foreach (Analyzer.State.Limb[] p in possibilities) { State nxt = ArcCalculator.TransitionTo(cur, p, n.second, n.distance_from_start, beat, cost_factory); if (nxt != null) { //tmp.Add(nxt); opened.Add(nxt); } } } } } return result; }
public PremiumState(State state) { this.nextPage = "Premium Main Page"; this.user = state.User; Initialize(); }
public void PresentadorInformacion(string _cLine) { lGuardarRegistro Save = new GuardarRegistro(); lInicializarTrasporteEmpresas srvInitDatos = new InicializarDatos(); lObtenerFecha lobtenerFecha = new ObtenerFecha("27/01/2020"); string[] _lstInformacion = _cLine.Split(','); lPresentadorTexto presentadorTexto = new PresentadorTexto(); lBuscarMejorOpcion buscarMejorOpcion = new BuscarMejorOpcion(); lAsignarDatosEnvio lasignarDatosEnvio = new AsignarDatosEnvio(); Context context = new Context(); lConvertirTipoDato convertirTipoDato = new CovertirTipoDatoService(); double dTiempoTraslado = 0; decimal TiempoTraslado = 0; decimal dCostoEnvio = 0; string cExpresion1 = ""; string cExpresion2 = ""; string cExpresion3 = ""; string cExpresion4 = ""; string cExpresion5 = ""; DateTime dtFechaEntrega = new DateTime(); DateTime dtHoy = lobtenerFecha.ObtenerFechaActual(); lEmpresas empresa = null; lEnvios transporte = null; EjecutarEstrategia ejecutarEstrategia = new EjecutarEstrategia(); List <lEmpresas> lstEmpresas = new List <lEmpresas>(); List <lEnvios> lstTransportes = new List <lEnvios>(); srvInitDatos.inicializarDatos(ref lstTransportes, ref lstEmpresas); lasignarDatosEnvio.AsignarEmpresa(_lstInformacion[3], ref empresa, lstEmpresas); lasignarDatosEnvio.AsignarTransporte(_lstInformacion[4], ref transporte, lstTransportes); if (empresa != null) { Pedido initialState = new DesactivarState(); State.State entPedido = new State.State(initialState, _lstInformacion[0], _lstInformacion[1], convertirTipoDato.ConvertirStringADecimal(_lstInformacion[2]), empresa, transporte, Convert.ToDateTime(_lstInformacion[5])); initialState.setContext(entPedido); TiempoTraslado = empresa.TiempoTraslado(entPedido); if (TiempoTraslado > 0) { dTiempoTraslado = convertirTipoDato.ConvertirDecimalADouble(TiempoTraslado); dtFechaEntrega = empresa.FechaEntrega(dTiempoTraslado, entPedido); dCostoEnvio = empresa.CostoEnvio(entPedido); string[] lstExpresiones = { cExpresion1, cExpresion2, cExpresion3, cExpresion4, cExpresion5 }; ejecutarEstrategia.Ejecutar(ref lstExpresiones, context, dtFechaEntrega, dtHoy, entPedido); if (entPedido.state.ToString() == "State.ActivarState") { presentadorTexto.CambiarEstiloTexto(ConsoleColor.Green); } else { presentadorTexto.CambiarEstiloTexto(ConsoleColor.Yellow); } string cResultado = $"Tu paquete {lstExpresiones[0]} de {entPedido.cOrigen} y {lstExpresiones[1]} a {entPedido.cDestino} {lstExpresiones[2]} {lstExpresiones[4]} y {lstExpresiones[3]} un costo de {dCostoEnvio} (Cualquier reclamación con {_lstInformacion[3]})."; Console.WriteLine(cResultado); Save.guardarRegistro(lstExpresiones, cResultado, empresa.cNombre); presentadorTexto.CambiarEstiloTexto(ConsoleColor.Blue); Console.WriteLine(buscarMejorOpcion.ObtenerMejorOpcion(lstEmpresas, empresa, entPedido, dCostoEnvio)); } else { presentadorTexto.CambiarEstiloTexto(ConsoleColor.Red); Console.WriteLine($"{_lstInformacion[3]} no ofrece el servicio de transporte {entPedido.cMedioTransporte.cNombre}, te recomendamos cotizaren otra empresa."); } } else { presentadorTexto.CambiarEstiloTexto(ConsoleColor.Red); Console.WriteLine($"La Paquetería: {_lstInformacion[3]} no se encuentra registrada en nuestra red de distribución."); } }
public NormalState(State state) { this.con = state.con; }
public RestrictedState(State state) { this.con = state.con; }
public LoggedOutState(State state) { this.nextPage = "Login Page"; this.user = state.User; Initialize(); }
public void setState(State state) { this.state = state; }
public void SetCurrentState(bool left) { var p = _palette.FirstOrDefault(surf => surf.Get().Any(seg => seg.Selected)); if (p != null) { var pType = p.Get().First().Type; switch (pType) { case ElementType.Line: CurrentState = new LineState { Left = left }; break; case ElementType.Cursor: CurrentState = new CursorState(); break; case ElementType.Properties: CurrentState = new PropertiesState(); break; case ElementType.None: break; default: CurrentState = new PaletteState(); break; } } else { var pos = Surface.Get().FirstOrDefault(seg => seg.Selected); var lineState = CurrentState as LineState; if (lineState != null && (lineState.LeftSegment == null || lineState.RightSegment == null)) { lineState.Handle(CurrentState, PrevSegment, NewSegment, left); return; } if (pos != null) { var posType = pos.Type; switch (posType) { case ElementType.None: CurrentState = new EmptyState(); break; case ElementType.Coil: case ElementType.Latch: case ElementType.NcContact: case ElementType.NoContact: case ElementType.NotCoil: case ElementType.OffTimer: case ElementType.OnTimer: case ElementType.PulseTimer: case ElementType.CycleTimer: case ElementType.SetCoil: case ElementType.ResetCoil: CurrentState = new ElementState(); break; case ElementType.Line: CurrentState = new LineState(); break; default: throw new ArgumentException(Enum.GetName(typeof(ElementType), posType)); } } } }
public void SetCurrentState(bool left) { var p = _palette.FirstOrDefault(surf => surf.Get().Any(seg => seg.Selected)); if (p != null) { var pType = p.Get ().First ().Type; switch (pType) { case ElementType.Line: CurrentState = new LineState {Left = left}; break; case ElementType.Cursor: CurrentState = new CursorState (); break; case ElementType.Properties: CurrentState = new PropertiesState (); break; case ElementType.None: break; default: CurrentState = new PaletteState (); break; } } else { var pos = Surface.Get ().FirstOrDefault (seg => seg.Selected); var lineState = CurrentState as LineState; if ( lineState != null && (lineState.LeftSegment == null || lineState.RightSegment == null)) { lineState.Handle (CurrentState, PrevSegment, NewSegment, left); return; } if (pos != null) { var posType = pos.Type; switch (posType) { case ElementType.None: CurrentState = new EmptyState (); break; case ElementType.Coil: case ElementType.Latch: case ElementType.NcContact: case ElementType.NoContact: case ElementType.NotCoil: case ElementType.OffTimer: case ElementType.OnTimer: case ElementType.PulseTimer: case ElementType.CycleTimer: case ElementType.SetCoil: case ElementType.ResetCoil: CurrentState = new ElementState (); break; case ElementType.Line: CurrentState = new LineState (); break; default: throw new ArgumentException (Enum.GetName (typeof(ElementType), posType)); } } } }
public TravelManager() { state = India.Instance(); }
internal void ChangeState(State s) { State = s; }
public OverdraftState(State state) { this.con = state.con; }
public static State GenerateInitialNode (bool is_double, ICostFactory cost_factory) { State initial = new State(null, 0.0f, -1, false); initial.limbs[0] = new Analyzer.State.Limb(); initial.limbs[1] = new Analyzer.State.Limb(); if (is_double) { initial.limbs[0].main = new Analyzer.State.Part( Analyzer.State.Movement.PassiveDown, Panel.Panels_1D_Playable[4], 0.0f, 0.0f, 0.0f ); initial.limbs[0].sub = new Analyzer.State.Part( Analyzer.State.Movement.PassiveDown, Panel.Panels_1D_Playable[3], 0.0f, 0.0f, 0.0f ); initial.limbs[0].extra = new Analyzer.State.Part( Analyzer.State.Movement.Unknown, null, 0.0f, 0.0f, 0.0f ); initial.limbs[1].main = new Analyzer.State.Part( Analyzer.State.Movement.PassiveDown, Panel.Panels_1D_Playable[5], 0.0f, 0.0f, 0.0f ); initial.limbs[1].sub = new Analyzer.State.Part( Analyzer.State.Movement.PassiveDown, Panel.Panels_1D_Playable[6], 0.0f, 0.0f, 0.0f ); initial.limbs[1].extra = new Analyzer.State.Part( Analyzer.State.Movement.Unknown, null, 0.0f, 0.0f, 0.0f ); } else { initial.limbs[0].main = new Analyzer.State.Part( Analyzer.State.Movement.PassiveDown, Panel.Panels_1D_Playable[0], 0.0f, 0.0f, 0.0f ); initial.limbs[0].sub = new Analyzer.State.Part( Analyzer.State.Movement.PassiveDown, Panel.Panels_1D_Playable[1], 0.0f, 0.0f, 0.0f ); initial.limbs[0].extra = new Analyzer.State.Part( Analyzer.State.Movement.Unknown, null, 0.0f, 0.0f, 0.0f ); initial.limbs[1].main = new Analyzer.State.Part( Analyzer.State.Movement.PassiveDown, Panel.Panels_1D_Playable[4], 0.0f, 0.0f, 0.0f ); initial.limbs[1].sub = new Analyzer.State.Part( Analyzer.State.Movement.PassiveDown, Panel.Panels_1D_Playable[3], 0.0f, 0.0f, 0.0f ); initial.limbs[1].extra = new Analyzer.State.Part( Analyzer.State.Movement.Unknown, null, 0.0f, 0.0f, 0.0f ); } initial.facing = new Vector(0.0f, 1.0f); initial.facing_desired = new Vector(0.0f, 1.0f); initial.sanityCheck(); initial.cost = cost_factory.Calculate(initial); return initial; }
public void ChangeState(TravelManager tm, State s) { tm.ChangeState(s); }
// Constructor public RedState(State state) { this.balance = state.Balance; this.account = state.Account; Initialize(); }
public Context(State state) { _state = state; }
public DateTime FechaEntrega(double _TiempoTraslado, State.State _entPedido) { DateTime FechaEntrega = _entPedido.dtFechaHora.AddHours(_TiempoTraslado); return(FechaEntrega); }
// Overloaded constructors public GoldState(State state) : this(state.Balance, state.Account) { }
// Constructor public Context(State state) { this.State = state; }
// Overloaded constructors public SilverState(State state) : this(state.Balance, state.Account) { }
public void Add (State item) { m_Items[m_Count++] = item; ++m_TotalAdded; }
public User(string name) { this.name = name; this.state = new LoggedOutState(this); }