Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            try
            {
                //for this execise I tried to implement S.O.L.I.D

                IRepositoryTank tank = new Tank();


                IWaterAnimal fish = TankFactory.Create<AngelFish>();
                fish.Name = String.Empty;
                fish.PortionFood = 0;
                tank.Add<AngelFish>((AngelFish)fish);

                fish = TankFactory.Create<GoalFish>();
               
                fish.Name = "GoalFish";
                fish.PortionFood = 0.1;
                tank.Add<GoalFish>((GoalFish)fish);


                fish = TankFactory.Create<BabelFish>();
                fish.Name = "GoalFish";
                fish.PortionFood = 0.3;
                tank.Add<BabelFish>((BabelFish)fish);


                



                Console.WriteLine("Added 3 new type of  fish in the tank");


                double foodNeeded = Math.Round(tank.Feed(), 4);

                Console.WriteLine("Tank Need {0} g of food for this fish ", foodNeeded);


                tank.AddToXmlAndSaveChanges();

                Console.WriteLine("Tank has saved this irformation to an xml document. ");
            }
            catch (Exception ex)
            {
                //loger.log(String.Format("Error. {0}", ex.Message)).
                Console.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }