示例#1
0
        static void Main(string[] args)
        {
            // Задание 1
            Student a = new Student()
            {
                Id = 247909
            };
            Student b = new Student()
            {
                Id = 285428
            };
            Student c = new Student()
            {
                Id = 285417
            };
            List <Student> students = new List <Student>();

            students.Add(a);
            students.Add(b);
            students.Add(c);

            Console.WriteLine("Задание 1");
            PrintStudentID(0, students);
            PrintStudentID(1, students);
            PrintStudentID(2, students);

            // Задание 2
            DoublyLinkedList <ColorPalette> ColorPalettes = new DoublyLinkedList <ColorPalette>();
            ColorPalette Red   = new ColorPalette("Красный");
            ColorPalette Green = new ColorPalette("Зелёный");
            ColorPalette Blue  = new ColorPalette("Синий");

            ColorPalettes.Add(Red);
            ColorPalettes.Add(Green);
            ColorPalettes.Add(Blue);
            var ColorPalette = ColorPalettes.GetHead();

            Console.WriteLine();
            Console.WriteLine("Задание 2");
            do
            {
                Console.Write($"{ColorPalette.Data.color} ");
                ColorPalette = ColorPalette.Next;
            }while (ColorPalette != null);
            Console.Write("\n");

            // Задание 3
            CircularDoublyLinkedList <ColorPalette> trafficLights = new CircularDoublyLinkedList <ColorPalette>();
            ColorPalette Orange = new ColorPalette("Оранжевый");

            trafficLights.Add(Red);
            trafficLights.Add(Orange);
            trafficLights.Add(Green);
            var trafficLightsColorPalette = trafficLights.GetHead();

            Console.WriteLine();
            Console.WriteLine("Задание 3");
            for (int i = 0; i != 3 * trafficLights.GetCount(); i++)
            {
                Console.Write($"{trafficLightsColorPalette.Data.color} ");
                trafficLightsColorPalette = trafficLightsColorPalette.Next;
            }

            // Задание 4
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Задание 4");
            RestrictedQueue <ColorPalette> Gun = new RestrictedQueue <ColorPalette>()
            {
                Limit = 2, LimitErrorMassage = "Пистолет полон", EmptyErrorMassage = "Пистолет пуст"
            };

            AddСolorIntoGun(Gun, Orange);
            ShootСolor(Gun);
            AddСolorIntoGun(Gun, Blue);
            AddСolorIntoGun(Gun, Red);
            AddСolorIntoGun(Gun, Green);
            ShootСolor(Gun);
            ShootСolor(Gun);
            ShootСolor(Gun);

            // Задание 5
            Console.WriteLine();
            Console.WriteLine("Задание 5");
            RestrictedStack <ColorPalette> colorBasket = new RestrictedStack <ColorPalette>()
            {
                hasLimit = true, Limit = 2, LimitErrorMassage = "Обойма заполнена", EmptyErrorMassage = "Обойма пуста"
            };

            PutСolorIntoСartridge(Orange, colorBasket);
            PutСolorIntoСartridge(Blue, colorBasket);
            PutСolorIntoСartridge(Red, colorBasket);
            GetСolorFromСartridge(colorBasket);
            GetСolorFromСartridge(colorBasket);
            PutСolorIntoСartridge(Red, colorBasket);

            // Задание 6
            Console.WriteLine();
            Console.WriteLine("Задание 6");
            LinkedStack <ColorPalette> iceCream = new LinkedStack <ColorPalette>();

            AddColorInIceCream(iceCream, Orange);
            AddColorInIceCream(iceCream, Blue);
            EatColor(iceCream);
            AddColorInIceCream(iceCream, Red);
            EatColor(iceCream);
            EatColor(iceCream);

            // Задание 7
            Console.WriteLine();
            Console.WriteLine("Задание 7");
            PostfixExpressions postfixExpressions = new PostfixExpressions();

            Calculate(postfixExpressions);
            Calculate(postfixExpressions);
        }
示例#2
0
 private static void AddColorInIceCream(LinkedStack <ColorPalette> iceCream, ColorPalette color)
 {
     iceCream.Push(color);
     Console.WriteLine($"Мороженное цвета {color.color}");
 }
示例#3
0
 public float Calculate(string input)
 {
     operatorsStack = new LinkedStack <char>();
     quantityStack  = new LinkedStack <float>();
     return(Counting(GetExpression(input)));
 }
示例#4
0
        private static void EatColor(LinkedStack <ColorPalette> iceCream)
        {
            var color = iceCream.Pop();

            Console.WriteLine($"{color.color} мороженое съели");
        }