Example #1
0
 public void changeRight(EndOfLines newEnd)
 {
     this.endRight = newEnd.R();
     if (changed != null)
     {
         changed(this, new Test(2));
     }
 }
Example #2
0
 public void changeLeft(EndOfLines newEnd)
 {
     this.endLeft = newEnd.L();
     changed?.Invoke(this, new Test(3));
 }
Example #3
0
 public Line(int len, EndOfLines left, EndOfLines right)
 {
     this.body     = new string('-', len);
     this.endLeft  = left.L();
     this.endRight = right.R();
 }
Example #4
0
        static void Main(string[] args)
        {
            int    i      = 1;
            int    Lenght = 0;
            string Left   = "";
            string Right  = "";

            while (i < 10)
            {
                Console.WriteLine(i + " line. Make you line:");

                Console.Write("Length: ");
                Lenght = int.Parse(Console.ReadLine());

                Console.Write("Left (dot / arrow / rhomb): ");
                Left = Console.ReadLine();

                Console.Write("Right (dot / arrow / rhomb): ");
                Right = Console.ReadLine();

                if ((Left == "dot" || Left == "arrow" || Left == "rhomb") && (Right == "dot" || Right == "arrow" || Right == "rhomb"))
                {
                    EndOfLines endLeft  = null;
                    EndOfLines endRight = null;

                    switch (Left)
                    {
                    case "dot":
                        endLeft = new Dot();
                        break;

                    case "arrow":
                        endLeft = new Arrow();
                        break;

                    case "rhomb":
                        endLeft = new Rhomb();
                        break;

                    default:
                        break;
                    }

                    switch (Right)
                    {
                    case "dot":
                        endRight = new Dot();
                        break;

                    case "arrow":
                        endRight = new Arrow();
                        break;

                    case "rhomb":
                        endRight = new Rhomb();
                        break;

                    default:
                        break;
                    }

                    Line newLine = new Line(Lenght, endLeft, endRight);

                    Console.WriteLine("!====================!");
                    Console.WriteLine();

                    Console.WriteLine(newLine.Draw());

                    Console.WriteLine();
                    Console.WriteLine("!====================!");
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("repeat");
                }

                i++;
            }
            //List<int[]> points = new List<int[]>();
            //string[] xy = { "X1=", "\tY1=", "\tX2=", "\tY2=" };
            //Random rnd = new Random();
            //while (true)
            //{
            //    Console.WriteLine("1. add line (none, none)");
            //    Console.WriteLine("2. add line (strelka, strelka)");
            //    Console.WriteLine("3. add line (romb, romb)");
            //    Console.WriteLine("4. print lines");
            //    switch (Console.ReadLine())
            //    {
            //        case "1": points.Add(new int[]{
            //        rnd.Next(-10, 11),rnd.Next(-10, 11),
            //        rnd.Next(-10, 11),rnd.Next(-10, 11),
            //        1,1}); break;
            //        case "2": points.Add(new int[]{
            //        rnd.Next(-10, 11),rnd.Next(-10, 11),
            //        rnd.Next(-10, 11),rnd.Next(-10, 11),
            //        2,2}); break;
            //        case "3": points.Add(new int[]{
            //        rnd.Next(-10, 11),rnd.Next(-10, 11),
            //        rnd.Next(-10, 11),rnd.Next(-10, 11),
            //        3,3}); break;
            //        case "4":
            //            foreach (int[] point in points)
            //            {
            //                for (int i = 0; i < 4; i++)
            //                    Console.Write(xy[i] + point[i]);
            //                switch (point[4])
            //                {
            //                    case 1: Console.Write("\t(none, "); break;
            //                    case 2: Console.Write("\t(strelka, "); break;
            //                    case 3: Console.Write("\t(romb, "); break;
            //                }
            //                switch (point[5])
            //                {
            //                    case 1: Console.Write("none)"); break;
            //                    case 2: Console.Write("strelka)"); break;
            //                    case 3: Console.Write("romb)"); break;
            //                }
            //                Console.WriteLine();
            //            }
            //            break;
            //        default:
            //            Console.WriteLine("Неизвестная команда");
            //            break;
            //    }
            //    Console.WriteLine();
            //}
        }
Example #5
0
 public void changeRight(EndOfLines newEnd)
 {
     this.endLeft = newEnd.R();
 }
Example #6
0
 public void changeLeft(EndOfLines newEnd)
 {
     this.endLeft = newEnd.L();
 }
Example #7
0
        static void Main(string[] args)
        {
            /*
             * for (int i = 0; i < 10; i++)
             * {
             *  Console.Clear();
             *  ShowRandom();
             *  Console.ReadLine();
             *  Show();
             *  Console.ReadLine();
             * }
             */
            ShowRandom();

            for (int j = 0; j < 10; j++)
            {
                Console.WriteLine("Choose line to change (max = " + lines_body.Count + ")");
                int index = int.Parse(Console.ReadLine()) - 1;
                Console.WriteLine("Choose left ends (dot / arrow / rhomb)");
                string left = Console.ReadLine();

                if (left == "")
                {
                    left = "dot";
                }

                Console.WriteLine("Choose right ends (dot / arrow / rhomb)");
                string right = Console.ReadLine();

                if (right == "")
                {
                    right = "dot";
                }

                if (index < lines_body.Count && index >= 0 && (left == "dot" || left == "arrow" || left == "rhomb") && (right == "dot" || right == "arrow" || right == "rhomb"))
                {
                    EndOfLines leftE = null, rightE = null;

                    switch (left)
                    {
                    case "dot":
                        leftE = new Dot();
                        break;

                    case "arrow":
                        leftE = new Arrow();
                        break;

                    case "rhomb":
                        leftE = new Rhomb();
                        break;

                    default:
                        break;
                    }

                    switch (right)
                    {
                    case "dot":
                        rightE = new Dot();
                        break;

                    case "arrow":
                        rightE = new Arrow();
                        break;

                    case "rhomb":
                        rightE = new Rhomb();
                        break;

                    default:
                        break;
                    }

                    lines_body[index].changeLeft(leftE);
                    lines_body[index].changeRight(rightE);
                }
                else
                {
                    Console.WriteLine("No, sorry");
                }
            }
        }