Exemplo n.º 1
0
        public static void TaskA(Invoice[] array)
        {
            var sortedByPartDescription =
                from value in array
                orderby value.PartDescription
                select value;

            foreach (var value in sortedByPartDescription)
            {
                Console.WriteLine(value.ToString());
            }
            Console.WriteLine();
        }
        public static void Main()
        {
            Invoice invoice1 = new Invoice(10, "invoice1", 1, 100m);
            Invoice invoice2 = new Invoice(2, "invoice2", 4, 10m);
            Invoice invoice3 = new Invoice(12, "invoice3", 5, 132m);
            Invoice invoice4 = new Invoice(5, "invoice4", 2, 910m);
            Invoice invoice5 = new Invoice(123, "binvoice5", 3, 91m);
            Invoice invoice6 = new Invoice(40, "ccinvoice6", 10, 45m);
            Invoice invoice7 = new Invoice(0, "invoice7", 100, 120m);
            Invoice invoice8 = new Invoice(7, "invoice8", 11, 1000m);

            Invoice[] array = new Invoice[]{
                invoice1,invoice2,invoice3,invoice4,invoice5,invoice6,invoice7,invoice8
            };

            Invoice.TaskA(array);
            Invoice.TaskB(array);
            Invoice.TaskC(array);
            Invoice.TaskD(array);
            Invoice.TaskE(array);
            Invoice.TaskF(array);
            Invoice.TaskG(array);
        }
Exemplo n.º 3
0
        public static void TaskB(Invoice[] array)
        {
            var sortedByPrice =
                from value in array
                orderby value.Price
                select value;

            foreach (var value in sortedByPrice)
            {
                Console.WriteLine(value.ToString());
            }
            Console.WriteLine();
        }
Exemplo n.º 4
0
        public static void TaskG(Invoice[] array)
        {
            var firstCol =
                from value in array
                where value.Price >= 20
                select value;

            Console.WriteLine("Category: Price above 20$");
            foreach (var value in firstCol)
            {
                Console.WriteLine(value.ToString());
            }

            var secondCol =
                from value in array
                where value.Price <= 10
                select value;

            Console.WriteLine("Category: Price below 10$");
            foreach (var value in secondCol)
            {
                Console.WriteLine(value.ToString());
            }

            var thirdCol =
                from value in array
                where value.Price > 10 && value.Price < 20
                select value;

            Console.WriteLine("Category: Price between 10$ and 20$");
            foreach (var value in secondCol)
            {
                Console.WriteLine(value.ToString());
            }
            Console.WriteLine();
        }
Exemplo n.º 5
0
        public static void TaskF(Invoice[] array)
        {
            var firstCol =
                from value in array
                where value.Price > 12
                select value;

            Console.WriteLine("Category: Price above 12$");
            foreach (var value in firstCol)
            {
                Console.WriteLine(value.ToString());
            }

            var secondCol =
                from value in array
                where value.Price <= 12
                select value;

            Console.WriteLine("Category: Price below 12$");
            foreach (var value in secondCol)
            {
                Console.WriteLine(value.ToString());
            }
            Console.WriteLine();
        }
Exemplo n.º 6
0
        public static void TaskE(Invoice[] array)
        {
            var printByRange =
                from value in array
                let total = value.Price * value.Quantity
                orderby total
                where total > 200 && total < 500
                select total;

            foreach (var value in printByRange)
            {
                Console.WriteLine(value.ToString());
            }
            Console.WriteLine();
        }
Exemplo n.º 7
0
        public static void TaskD(Invoice[] array)
        {
            var orderByTotal =
                from value in array
                let total = value.Price * value.Quantity
                orderby total
                select total;

            foreach (var value in orderByTotal)
            {
                Console.WriteLine(value.ToString());
            }
            Console.WriteLine();
        }
Exemplo n.º 8
0
        public static void TaskC(Invoice[] array)
        {
            var sortByQuantity =
                from value in array
                orderby value.Quantity
                select value;

            foreach (var value in sortByQuantity)
            {
                Console.WriteLine(value.ToString());
            }
            Console.WriteLine();
        }