コード例 #1
0
ファイル: Controller.cs プロジェクト: Sheleh01/LAB6
        public static void Find(Gym obj)
        {
            var display = from i in obj.data
                          orderby i.Shop
                          select i;

            Console.Write("Enter shop: ");
            string useshop = Convert.ToString(Console.ReadLine());

            foreach (tennis i in display)
            {
                if (i.Shop == useshop)
                {
                    Console.WriteLine("Shop name:" + i.Shop + " " + "Goods' price: " + i.price + " BYN");
                }
            }
        }
コード例 #2
0
ファイル: Controller.cs プロジェクト: Sheleh01/LAB6
        public static void FindCheaper(Gym obj)
        {
            var display = from i in obj.data
                          orderby i.price
                          select i;

            Console.Write("Enter price: ");
            int userprice = Convert.ToInt32(Console.ReadLine());

            foreach (tennis i in display)
            {
                if (i.price <= userprice)
                {
                    Console.WriteLine("Tennis name" + i.Shop + " "
                                      + "Goods' price: " + i.price + " BYN");
                }
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Ball ball1 = new Ball("HAF", "Max", "5ele", 5, 699);

            Console.WriteLine(ball1.ToString());
            Console.WriteLine(ball1.GetHashCode());
            Ball ball2 = new Ball("HAF", "izard", "5ele", 10, 1476);

            Console.WriteLine(ball2.Equals(ball1));

            Bball bb1 = new Bball("Pil", "lion", "Toni", 35, 2189);

            Console.WriteLine(bb1.ToString());

            if (bb1 is Ball) //принадлежит Ball?
            {
                Console.WriteLine("bb1 is ball");
            }
            else
            {
                Console.WriteLine("bb1 isn't ball");
            }
            Ball ball3 = bb1 as Ball; //преобразование в Ball

            ball3.ballModel = "Gaming";

            brus br1 = new brus("Central", "b 3", "5ele", 51, 539);

            Console.WriteLine(br1.ToString());

            mats mt1 = new mats("Max", "P-208II", "Toni", 7, 399);

            Console.WriteLine(mt1.ToString());

            bench bn1 = new bench("Max", "L805", "5ele", 16, 589);

            Console.WriteLine(bn1.ToString());



            Print.IAmPrinting(ball1);
            Print.IAmPrinting(ball2);
            Print.IAmPrinting(mt1);
            Print.IAmPrinting(bn1);


            MyStruct Projectile = new MyStruct("Sag", "Axy A+");

            Projectile.DisplayInfo();

            MyEnum xxx;

            xxx = MyEnum.tennis;
            switch (xxx)
            {
            case MyEnum.tennis:
            {
                Console.WriteLine("Is a tennis\n");
                break;
            }

            case MyEnum.brus:
            {
                Console.WriteLine("Is a brus\n");
                break;
            }

            case MyEnum.bench:
            {
                Console.WriteLine("Is a bench\n");
                break;
            }

            case MyEnum.mats:
            {
                Console.WriteLine("Is a mats\n");
                break;
            }
            }

            Gym lab = new Gym();

            lab.Push(ball1);
            lab.Push(mt1);
            lab.Push(bn1);
            lab.Push(br1);
            lab.Output();


            Controller.FindCheaper(lab);
            Controller.Find(lab);
            Console.ReadLine();
        }