Exemple #1
0
        static void Main(string[] args)
        {
            Product product = new Product("123", "213", 100);
            Tech    tech    = new Tech("456", "789", "456789", 200);
            Tablet  tablet  = new Tablet();
            Lab     lab     = new Lab(10);

            tablet.info.price = 300;
            lab.Add(product);
            lab.Add(tech);
            lab.Add(tablet);
            lab.Add(new Scanner());
            lab.Add(new Printer());
            lab.Add(new Product());

            lab.show();
            controller.show(lab);
            controller.sort(lab);
            lab.show();
            lab.Del(tablet);
            lab.show();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Product      product     = new Product("123", "213");
            Tech         tech        = new Tech("456", "789", "456789");
            Tablet       tablet      = new Tablet();
            IMyInterface myInterface = tablet;

            IAnotherInterface[] arr = new IAnotherInterface[3];
            arr[0] = product;
            arr[1] = tech;
            arr[2] = tablet;

            Console.WriteLine(product.ToString());
            Console.WriteLine(tech.ToString());
            Console.WriteLine(tablet.MyFunc());
            Console.WriteLine(myInterface.MyFunc());
            Console.WriteLine($"myInterface is IMyInterface = {myInterface is IMyInterface}");
            Console.WriteLine($"myInterface is Tabet = {myInterface is Tablet}");
            foreach (IAnotherInterface x in arr)
            {
                Print.IAmPrinting(x);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Random  random  = new Random();
            Student student = new Student("name", "2");
            Dictionary <double, double> dictionary       = new Dictionary <double, double>();
            Dictionary <double, Tablet> TabletDictionary = new Dictionary <double, Tablet>();
            Queue <double> queue       = new Queue <double>();
            Queue <Tablet> TabletQueue = new Queue <Tablet>();

            Tablet[] arr = new Tablet[5];
            ObservableCollection <Tablet> tablets = new ObservableCollection <Tablet>();

            tablets.CollectionChanged += StaticClass.method;

            ArrayList list = new ArrayList(10)
            {
                10, 20, 30, 40, 50
            };

            list.Add("string");
            list.Add(student);
            list.RemoveAt(2);
            Console.WriteLine($"Nubmer of elements: {list.Count}");
            foreach (object x in list)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine($"List contains 30 = {list.Contains(30)}");
            Console.WriteLine();

            dictionary.Add(random.NextDouble(), random.NextDouble());
            dictionary.Add(random.NextDouble(), random.NextDouble());
            dictionary.Add(random.NextDouble(), random.NextDouble());
            dictionary.Add(random.NextDouble(), random.NextDouble());
            dictionary.Add(random.NextDouble(), random.NextDouble());

            foreach (KeyValuePair <double, double> x in dictionary)
            {
                Console.WriteLine(x);
                queue.Enqueue(x.Value);
            }
            Console.WriteLine();

            foreach (double x in queue)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine();

            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = new Tablet();
                TabletDictionary.Add(arr[i].GetHashCode(), arr[i]);
            }
            Console.WriteLine();

            foreach (KeyValuePair <double, Tablet> x in TabletDictionary)
            {
                Console.WriteLine(x);
                TabletQueue.Enqueue(x.Value);
            }
            Console.WriteLine();

            foreach (Tablet x in TabletQueue)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine();

            foreach (Tablet x in arr)
            {
                tablets.Add(x);
            }
            tablets.RemoveAt(3);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Product product = new Product("123", "213", 100);
            Tech    tech    = new Tech("456", "789", "456789", 200);
            Tablet  tablet  = new Tablet();
            Lab     lab     = new Lab(6);
            Scanner scanner = new Scanner("2223", "32131", "11123", "231", 22360);

            tablet.info.price = 300;
            IAnotherInterface[] arr = new IAnotherInterface[3];
            arr[0] = product;
            arr[1] = tech;
            arr[2] = tablet;

            try
            {
                Lab WrongLab = new Lab(100);
                WrongLab.Del(tablet);
                //arr[4].ToString();
                lab.Add(product);
                lab.Add(tech);
                lab.Add(tablet);
                lab.Add(new Scanner());
                lab.Add(new Printer());
                lab.Add(new Product());
                //lab.Add(new Product());


                lab.show();
                controller.show(lab);
                controller.sort(lab);
                lab.show();
                lab.Del(tablet);
                //lab.Del(scanner);
                lab.show();
            }
            catch (LabIsFull ex)
            {
                Console.WriteLine("LabIsFull Exception");
                Console.WriteLine(ex.Message);
            }
            catch (ElementDoesNotExist ex)
            {
                Console.WriteLine("ElementDoesNotExist Exception");
                Console.WriteLine(ex.Message);
            }
            catch (LabIsEmpty ex)
            {
                Console.WriteLine("LabIsEmpty Exception");
                Console.WriteLine(ex.Message);
            }
            catch (WrongSize ex)
            {
                Console.WriteLine("WrongSize Exception");
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Another Exception");
                Console.WriteLine(ex.Message);
            }
        }