private void ExecuteRequest()
        {
            var cargo = CargoFactory.Create(CurrentAction, CurrentPlace,
                                            CurrentRepairing, CurrentProduction,
                                            CurrentOrderType, SuppliesValue.ToString());

            try
            {
                Json = _communicationManager.Send(cargo);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                return;
            }
            GameState = JsonConverter.Parse(Json);
            LogManager.AddTurnReport(cargo, GameState);
            if (IsGameTerminated())
            {
                LogManager.GenerateLog();
            }
            if (IsGameTerminated() || HasGameBeenRestarted(cargo))
            {
                LogManager = new LogManager();
                LogManager.AddTurnReport(GameState);
            }
        }
Example #2
0
        public void TestCargoFactory()
        {
            CargoFactory cf = new CargoFactory();

            CargoDecorator cd = cf.Create();

            bool res = (cd is StandartCargoDecorator || cd is EncryptedCargoDecorator) && (cd.Cargo is StandartCargo ||
                                                                                           cd.Cargo is PerishableCargo || cd.Cargo is ToxicCargo);

            Assert.IsTrue(res);
        }
Example #3
0
        private Cargo[] GenerateCargoes(int count)
        {
            Cargo[]      cs = new Cargo[count];
            CargoFactory cf = new CargoFactory();

            for (int i = 0; i < count; i++)
            {
                cs[i] = cf.Create();
            }

            return(cs);
        }
Example #4
0
        public void Add(string[] parameters)
        {
            string model       = parameters[0];
            int    engineSpeed = int.Parse(parameters[1]);
            int    enginePower = int.Parse(parameters[2]);
            Engine engine      = engineFactory.Create(engineSpeed, enginePower);

            int    cargoWeight = int.Parse(parameters[3]);
            string cargoType   = parameters[4];
            Cargo  cargo       = cargoFactory.Create(cargoWeight, cargoType);

            Tire[] tires = GetTire(parameters.Skip(5).ToArray());

            Car car = carFactory.Create(model, engine, cargo, tires);

            this.Cars.Add(car);
        }