public void Initialize()
        {
            _gift = new Gift("GiftFofSTEM", new List <ISweetness>());
            Candy     candy1 = new Candy("Сhupa Chups XXL 4D", 29, 0.65, 370, TypeOfCandy.Bars);
            Candy     candy2 = new Candy("Аэрофлотские", 150, 64.3, 483, TypeOfCandy.Chocolate);
            Chocolate choco1 = new Chocolate("Спартак", 75, 48, 540, TypeOfChocolate.Dark);
            Chocolate choco2 = new Chocolate("Любимая Алёнка", 200, 51.5, 550, TypeOfChocolate.Milk);

            _gift.AddSweet(candy1);
            _gift.AddSweet(candy2);
            _gift.AddSweet(choco1);
            _gift.AddSweet(choco2);
        }
Exemple #2
0
 public static void ToConsole(this IGift element)
 {
     Console.WriteLine("Подарок: ");
     foreach (var p in element.Elements)
     {
         Console.WriteLine("Элемент: {0}, имя: {1}, вес: {2}, сахар: {3}, калории: {4}"
                           , p.GetType().Name
                           , p.name
                           , p.weight
                           , p.sugar
                           , p.calories);
     }
     Console.WriteLine(new string('-', 75));
 }
Exemple #3
0
        internal static void AddGiftToExpectedGifts(IGift gift, string eventId)
        {
            var resultDict = new Dictionary <string, string>();
            var query      = string.Format(Queries.CURDQueries.Gifts.InsertExpectedGifts.InsertIntoGift, eventId, gift.getId());
            var sqlCommand = new SqlCommand();

            sqlCommand.CommandText = query;
            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();
                sqlCommand.Connection = conn;
                sqlCommand.ExecuteNonQuery();
                conn.Close();
            }
        }
        public IBaseObject Read(string id)
        {
            IGift gift = null;

            try
            {
                logger.InfoFormat("Getting gift from database for Id {0}", id);
                gift = (IGift)GiftDao.Read(id);
            }
            catch (Exception e)
            {
                logger.ErrorFormat("Error {1} occured while calling getting gift for id {0} ", id, e.Message);
            }
            return(gift);
        }
Exemple #5
0
        public static void ShowItems(this IGift gift)
        {
            Console.WriteLine("{0}, consist {1} elements", gift.GiftName, gift.CountOfSweet);
            Console.WriteLine();
            Console.WriteLine("Gift Weight: {0}", gift.GiftWeight);
            Console.WriteLine();
            Console.WriteLine("/-------------------------------------------/");
            Console.WriteLine();

            foreach (var i in gift.Items)
            {
                Console.WriteLine("{0}, {1}", i.TypeOfSweetness, i.ItemInfo);
            }
            Console.WriteLine();
            Console.WriteLine("/-------------------------------------------/");
            Console.WriteLine("Sort Sweetness By Weight");
            Console.WriteLine();
            var temp = gift.SortSweetnessByWeight();

            foreach (var i in temp)
            {
                Console.WriteLine("{0}, {1}, {2}", i.TypeOfSweetness, i.Name, i.Weight);
            }
            Console.WriteLine();
            Console.WriteLine("/-------------------------------------------/");
            Console.WriteLine("Find Sweetness By Sugar ");
            Console.WriteLine();
            Console.WriteLine("Enter min value Sugar");
            var min = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter max value Sugar");
            var max = Convert.ToInt32(Console.ReadLine());


            foreach (var items in gift.FindSweetnessBySugar(min, max))
            {
                Console.WriteLine("Name: {0}, SugarPerUnit: {1}", items.Name, items.SugarPerUnit);
            }

            Console.ReadKey();
        }
Exemple #6
0
        private void Initialize()
        {
            _gift = new Gift("GiftFofSTEM", new List <ISweetness>());
            Candy     Konfetka  = new Candy("Барбариски", 10, 50, 100, TypeOfCandy.Caramel);
            Candy     Konfetka1 = new Candy("Бешенная пчелка", 15, 60, 250, TypeOfCandy.Dgele);
            Candy     Konfetka2 = new Candy("Ириска", 20, 75, 300, TypeOfCandy.Iric);
            Candy     Konfetka3 = new Candy("Чупа-чупс", 30, 65, 150, TypeOfCandy.Caramel);
            Candy     Konfetka4 = new Candy("Коровка", 25, 65, 220, TypeOfCandy.Milk);
            Candy     Konfetka5 = new Candy("Грильяж", 20, 35, 350, TypeOfCandy.Grillage);
            Candy     Konfetka6 = new Candy("Свежая капля", 13, 40, 70, TypeOfCandy.Milk);
            Chocolate chocolate = new Chocolate("Аленка", 100, 60, 540, TypeOfChocolate.Milk);

            _gift.AddSweet(Konfetka);
            _gift.AddSweet(Konfetka1);
            _gift.AddSweet(Konfetka2);
            _gift.AddSweet(Konfetka3);
            _gift.AddSweet(Konfetka4);
            _gift.AddSweet(Konfetka5);
            _gift.AddSweet(Konfetka6);
            _gift.AddSweet(chocolate);
        }
Exemple #7
0
 public BirthdayCake(IGift gift) : base(gift)
 {
 }
Exemple #8
0
    public ProductDecorator(IGift in_product)
    {
      this._Igift = in_product;

    }
Exemple #9
0
 public GiftDecorator(IGift in_product)
     : base(in_product)
 {
     this._In_product = in_product;
 }
Exemple #10
0
 public static void OnGiftSendedSuccess(IGift gift)
 {
     GiftSendedSuccess?.Invoke(gift);
 }
Exemple #11
0
 public CakeForEvent(IGift gift)
 {
     this.gift = gift;
 }
 public void AddGiftToExpectedGifts(IGift gift, string eventId)
 {
     logger.InfoFormat("Adding gift with id {0} to exepcted gift list {1}", gift.getId(), eventId);
     GiftDao.AddGiftToExpectedGifts(gift, eventId);
 }
 private void OnGiftSended(IGift gift)
 {
     Setup();
 }
Exemple #14
0
 public WeddingCake(IGift gift) : base(gift)
 {
 }
 public void CreateGift(IGift gift)
 {
     saveToFileFAO.WriteRecords(gift);
 }
Exemple #16
0
 public void SetGift(IGift gift)
 {
     Gift     = gift ?? throw new ArgumentNullException("Gift");
     HaveGift = true;
 }