Beispiel #1
0
        public Node ExprAdd()
        {
            var node = ExprMul();

            while (CurrentToken == TokenCategory.PLUS || CurrentToken == TokenCategory.MINUS)
            {
                if (CurrentToken == TokenCategory.MINUS)
                {
                    var node_minus = new Minus();
                    node_minus.AnchorToken = Expect(TokenCategory.MINUS);
                    node_minus.Add(node);
                    node_minus.Add(ExprMul());
                    node = node_minus;
                }
                else
                {
                    var node_plus = new Plus();
                    node_plus.AnchorToken = Expect(TokenCategory.PLUS);
                    node_plus.Add(node);
                    node_plus.Add(ExprMul());
                    node = node_plus;
                }
            }
            return(node);
        }
Beispiel #2
0
    public Node Expr()
    {
        var r = Term();

        while (Current == TokenCategory.PLUS)
        {
            var p = new Plus()
            {
                AnchorToken = Expect(TokenCategory.PLUS)
            };
            p.Add(r);
            p.Add(Term());
            r = p;
        }
        return(r);
    }
Beispiel #3
0
    public Node Expr()
    {
        var n1 = Term();

        while (Current == TokenCategory.PLUS)
        {
            var n2 = new Plus()
            {
                AnchorToken = Expect(TokenCategory.PLUS)
            };
            n2.Add(n1);
            n2.Add(Term());
            n1 = n2;
        }
        return(n1);
    }
Beispiel #4
0
    public Node Exp()
    {
        var result = Term();

        while (Current == TokenCategory.PLUS)
        {
            var node = new Plus()
            {
                AnchorToken = Expect(TokenCategory.PLUS)
            };
            node.Add(result);
            node.Add(Term());
            result = node;
        }
        return(result);
    }
Beispiel #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Dostępne produkty: mleko, chleb, cukier. \nAby dodać mleko wybierz 1, chleb - wybierz 2, cukier - wybierz 3");
            string input   = Console.ReadLine();
            int    produkt = Convert.ToInt32(input);

            switch (produkt)
            {
            case 1:
                Milk milk = new Milk();
                milk.AddToCart();
                break;

            case 2:
                Bread bread = new Bread();
                bread.AddToCart();
                break;

            default:
                Console.WriteLine("Wybrany produkt nie istnieje ");
                break;
            }

            //if
            int x = 5;

            if (x == 1)
            {
                Console.WriteLine("1");
            }
            else if (x == 2)
            {
                Console.WriteLine("2");
            }

            else if (x == 3)
            {
                Console.WriteLine("3");
            }

            else if (x == 4)
            {
                Console.WriteLine("4");
                Console.WriteLine("4");
                Console.WriteLine("4");
            }
            //default
            else
            {
                Console.WriteLine("Nic nie zostało wybrane");
            }


            if (x < 5)
            {
                Console.WriteLine("<5");
            }
            else if (x > 5)
            {
                Console.WriteLine(">5");
            }
            //default
            else
            {
                Console.WriteLine("Nic nie zostało wybrane");
            }

            int z = 11;

            switch (z)
            {
            case 1:
                Plus plus = new Plus();
                plus.Add(5, 6);
                break;

            case 2:
                Minus minus = new Minus();
                minus.Subtract(10, 3);
                break;

            default:

                Console.WriteLine("Brak");
                break;
            }


            List <int> numList = new List <int>()
            {
                11, 22, 33, 88
            };

            for (int i = 0; i < numList.Count(); i++)
            {
                Console.WriteLine(numList[1]);
            }

            //list of strings
            List <string> elementKolekcji = new List <string>()
            {
                "string", "spring", "sphinx", "bring"
            };


            //list of strings
            foreach (string e in elementKolekcji)
            {
                Console.WriteLine(e);
            }

            Console.ReadLine();

            //tab of int
            int[] tab = { 1, 2, 3, 7, 9 };

            foreach (int y in tab)
            {
                Console.WriteLine(y);
            }

            Console.ReadLine();

            //tab of strings

            string[] dong = { "ping", "pong", "strong" };
            foreach (string d in dong)
            {
                Console.WriteLine(d);
            }
            Console.ReadLine();
        }