Example #1
0
        public static void PriceSearch()
        {
            Console.WriteLine("input > for items of cost or above or < for items of cost or below");
            var    inventory = new ItemInventory().GetAllItems();
            string input     = Console.ReadLine();
            double search    = double.Parse(Console.ReadLine());

            if (input == ">")
            {
                var HoldItem =
                    from i in inventory
                    where i.Price >= search
                    orderby i.Price ascending
                    select i;

                foreach (Item i in HoldItem)
                {
                    Console.WriteLine("Price: {1}\t Category: {2}\t Name: {0}", i.Name, i.Price, i.Cat);
                }
            }
            else if (input == "<")
            {
                var HoldItem =
                    from i in inventory
                    where i.Price <= search
                    orderby i.Price descending
                    select i;

                foreach (Item i in HoldItem)
                {
                    Console.WriteLine("Price: {1}\t Category: {2}\t Name: {0}", i.Name, i.Price, i.Cat);
                }
            }
            else
            {
                return;
            }
        }
Example #2
0
 //constructor
 public ShopHandler()
 {
     inventory = new ItemInventory();
 }