Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //------------------------------------Factory---------------------------------------

            ShipFactory factory = new ShipFactory();
            List <Ship> ships   = new List <Ship>();

            Console.WriteLine("Enter type of ship U / R / B");
            String a = Console.ReadLine();
            Ship   s = factory.makeShip(a);

            ships.Add(s);
            Console.WriteLine("Enter type of ship U / R / B");
            a = Console.ReadLine();
            s = factory.makeShip(a);
            ships.Add(s);
            foreach (Ship ship in ships)
            {
                Console.WriteLine(ship);
            }
            ships.Clear();
            //------------------------------------ABSTRACTING FACTORIES---------------------------------------


            ships.Add(ShipBuilding.orderShip("UFO"));
            ships.Add(ShipBuilding.orderShip("BIG UFO"));
            ships.Add(ShipBuilding.orderShip("ROCK"));
            foreach (Ship ship in ships)
            {
                Console.WriteLine(ship);
            }
            Console.ReadLine();
        }
        public override Ship makeShip(string type)
        {
            Ship rockship = null;

            if (type == "ROCK")
            {
                ShipFactory factory = new ShipFactory();
                rockship        = factory.makeShip("R");
                rockship.Speed += ((RocketShip)rockship).GetFirePower();
            }
            //... alte tipuri de racheta
            return(rockship);
        }
Ejemplo n.º 3
0
        public override Ship makeShip(string type)
        {
            Ship ufoship = null;

            if (type == "UFO")
            {
                ShipFactory factory = new ShipFactory();

                ufoship      = factory.makeShip("U");
                ufoship.Name = "UFO new Ship";
            }
            if (type == "BIG UFO")
            {
                ShipFactory factory = new ShipFactory();

                ufoship      = factory.makeShip("B");
                ufoship.Name = "UFO Boss Ship";
            }


            return(ufoship);
        }