예제 #1
0
        private void Find_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            var min   = Convert.ToDouble(textBoxMinSugar.Text);
            var max   = Convert.ToDouble(textBoxMaxSugar.Text);
            var gifts = _gift.FindSweetnessBySugar(min, max);

            for (int i = 0; i < gifts.Count(); i++)
            {
                listBox1.Items.Insert(i, String.Format("Name: {0}, SugarPerUnit: {1}",
                                                       gifts.ElementAt(i).Name, gifts.ElementAt(i).SugarPerUnit));
            }
        }
예제 #2
0
        private void Find_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();

            int j = 0;

            double min  = Convert.ToDouble(minsugar.Text);
            double max  = Convert.ToDouble(maxsugar.Text);
            var    temp = _gift.FindSweetnessBySugar(min, max);

            foreach (var i in temp)
            {
                listBox1.Items.Insert(j, String.Format("Name: {0}," + "SugarPerUnit: {1}", i.Name, i.SugarPerUnit));
                j++;
            }
        }
예제 #3
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();
        }