Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var fastCamel     = new FastCamel();
            var bactrianCamel = new BactrianCamel();
            var centaur       = new Centaur();
            var boots         = new MagicalBoots();
            var broom         = new Broomstick();
            var carpet        = new MagicCarpet();
            var mortar        = new Mortar();

            var allRace = new AllTransportsRace(1000);

            allRace.AddTransport(fastCamel);
            allRace.AddTransport(bactrianCamel);
            allRace.AddTransport(centaur);
            allRace.AddTransport(boots);
            allRace.AddTransport(broom);
            allRace.AddTransport(carpet);
            allRace.AddTransport(mortar);
            allRace.PrintWinner();

            var airRace = new AirTransportsRace(1000);

            airRace.AddTransport(mortar);
            airRace.AddTransport(broom);
            airRace.AddTransport(carpet);
            airRace.PrintWinner();

            var groundRace = new GroundTransportsRace(1000);

            groundRace.AddTransport(bactrianCamel);
            groundRace.AddTransport(centaur);
            groundRace.AddTransport(boots);
            groundRace.PrintWinner();
        }
Ejemplo n.º 2
0
        public void AddTransport(TransportType x)
        {
            ITransport newTransport;

            switch (x)
            {
            case TransportType.Centaur:
                newTransport = new Centaur();
                break;

            case TransportType.TwoCamel:
                newTransport = new TwoCamel();
                break;

            case TransportType.FastCamel:
                newTransport = new FastCamel();
                break;

            case TransportType.Boots:
                newTransport = new Boots();
                break;

            case TransportType.Broom:
                newTransport = new Broom();
                break;

            case TransportType.MagicCarpet:
                newTransport = new MagicCarpet();
                break;

            case TransportType.Mortar:
                newTransport = new Mortar();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(x), x, null);
            }

            try
            {
                _newRace.Add(newTransport);
            }
            catch (WrongParty e)
            {
                Console.WriteLine(e.Message);
                throw new CanNotBeAdd("Add problem");
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            AllTerrainBoots atb       = new AllTerrainBoots();
            FastCamel       fc        = new FastCamel();
            TwoHumpedCamel  thc       = new TwoHumpedCamel();
            Broom           b         = new Broom();
            FlyingCarpert   fl        = new FlyingCarpert();
            MultiRace       multiRace = new MultiRace(1000);

            multiRace.AddVehile(atb);
            multiRace.AddVehile(fc);
            multiRace.AddVehile(thc);
            multiRace.AddVehile(b);
            multiRace.AddVehile(fl);
            Vehicle v = multiRace.RunRace();

            Console.WriteLine(v.Speed);
        }