Exemple #1
0
        /// <summary>
        /// Returns the corrosponding object equal to the parameter
        /// </summary>
        public IRail GetObject(char pos)
        {
            switch (pos)
            {
            // rails
            case (char)Symbols.HoldingRail:
                return(new HoldingRail(Symbols.HoldingRail));

            case (char)Symbols.NormalRail:
                return(new NormalRail(Symbols.NormalRail));

            case (char)Symbols.CornerRailA:
                return(new NormalRail(Symbols.CornerRailA));

            case (char)Symbols.CornerRailB:
                return(new NormalRail(Symbols.CornerRailB));

            case (char)Symbols.StraightRail:
                return(new NormalRail(Symbols.StraightRail));

            // warehouses
            case (char)Symbols.WarehouseA:
                Warehouse wA = new Warehouse(Symbols.WarehouseA);
                _mainModel.AddWarehouse(Symbols.WarehouseA, wA);
                return(wA);

            case (char)Symbols.WarehouseB:
                Warehouse wB = new Warehouse(Symbols.WarehouseB);
                _mainModel.AddWarehouse(Symbols.WarehouseB, wB);
                return(wB);

            case (char)Symbols.WarehouseC:
                Warehouse wC = new Warehouse(Symbols.WarehouseC);
                _mainModel.AddWarehouse(Symbols.WarehouseC, wC);
                return(wC);

            // dock
            case (char)Symbols.Dock:
                Dock d = new Dock(Symbols.Dock);
                _mainModel.AddDock(d);
                return(d);

            case (char)Symbols.Water:
                return(new ShipRail(Symbols.Water));

            // wrong or empty symbol
            default:
                return(new EmptyRail(Symbols.EmptyRail));
            }
        }