Beispiel #1
0
        private static ResearchTeam CreateTeam()
        {
            var random    = new Random();
            var timeframe = frames[Math.Abs(random.Next()) % frames.Length];

            var paper = new Paper("C# sucks " + random.Next(), me, new DateTime());
            var team  = new ResearchTeam("402_" + random.Next(), "Suckers, all we are", random.Next(), timeframe);

            return(team);
        }
Beispiel #2
0
        private static int CreateSingleDimentionArray(params int[] parameters)
        {
            var count = parameters[0];

            singleDimentionArray = new ResearchTeam[count];

            for (int i = 0; i < count; i = 1 + i)
            {
                singleDimentionArray[i] = new ResearchTeam();
            }
            return(0);
        }
Beispiel #3
0
        private static int CreateTwoDimentionsArray(params int[] parameters)
        {
            var countRows = parameters[0];
            var countCols = parameters[1];

            twoDimentionsArray = new ResearchTeam[countRows, countCols];

            for (int i = 0; i < countRows; i = 1 + i)
            {
                for (int j = 0; j < countCols; j = 1 + j)
                {
                    twoDimentionsArray[i, j] = new ResearchTeam();
                }
            }
            return(0);
        }
Beispiel #4
0
        private static void OldTask()
        {
            var paper = new Paper("C# sucks", me, new DateTime());
            var team  = new ResearchTeam("402", "Suckers", 94362, TimeFrame.Long);

            Console.WriteLine(team.ToShortString());
            Console.WriteLine(team[TimeFrame.Year]);
            Console.WriteLine(team[TimeFrame.TwoYears]);
            Console.WriteLine(team[TimeFrame.Long]);

            Console.WriteLine(team);

            team.AddPaper(paper);

            Console.WriteLine(team.Paper.ToString());
        }
Beispiel #5
0
        private static int CreateJaggedArray(params int[] parameters)
        {
            var countRows = parameters[0];
            var countCols = parameters[1];

            jaggedArray = new ResearchTeam[countRows][];

            for (int i = 0; i < countRows; i = 1 + i)
            {
                var currentCount = (countCols + countRows / 2) - i;
                jaggedArray[i] = new ResearchTeam[currentCount];

                for (int j = 0; j < currentCount; j = 1 + j)
                {
                    jaggedArray[i][j] = new ResearchTeam();
                }
            }
            return(0);
        }
Beispiel #6
0
        public static void Main(string[] args)
        {
            ResearchTeam obj = new ResearchTeam();


            Console.WriteLine(obj.ToShortString());
            Console.WriteLine(obj[TimeFrame.Year]);
            Console.WriteLine(obj[TimeFrame.TwoYears]);
            Console.WriteLine(obj[TimeFrame.Long]);

            obj.DurationOfResearch = TimeFrame.TwoYears;
            obj.OrganizationName   = "Bionic";
            obj.RegistrationNumber = 0;
            obj.ResearchTopic      = "Snakes";

            Console.WriteLine(obj);

            Paper[] papers = new Paper[2];

            for (int i = 0; i < papers.Length; i++)
            {
                papers[i] = new Paper();
            }

            papers[0].Author          = new Person("Richard", "Markov", new DateTime(1897, 12, 11));
            papers[0].PublicationDate = new DateTime(2012, 12, 12);
            papers[0].PublicationName = "Cobra";

            papers[1].Author          = new Person("Nelly", "Stenly", new DateTime(1991, 4, 25));
            papers[1].PublicationDate = new DateTime(2015, 8, 22);
            papers[1].PublicationName = "Black Mamba";

            obj.AddPapers(papers);
            Console.WriteLine(obj);

            Console.WriteLine(obj.LastPublication);
        }
Beispiel #7
0
 protected bool Equals(ResearchTeam other)
 {
     return(string.Equals(_researchTopic, other._researchTopic) && _organizationTitle == other._organizationTitle && _registrationNumber.Equals(other._registrationNumber) && _researchDuration == other._researchDuration && Equals(_listOfPublication, other._listOfPublication));
 }
Beispiel #8
0
        static void Main(string[] args)
        {
            ResearchTeam RT = new ResearchTeam();

            Console.WriteLine(RT.ToShortString());
            Console.WriteLine(RT[TimeFrame.Year]);
            Console.WriteLine(RT[TimeFrame.TwoYears]);
            Console.WriteLine(RT[TimeFrame.Long]);
            RT.TopicOfResearch    = "Topic";
            RT.NameOfOrganisation = "Some Name";
            RT.RegistrationNumber = 12345;
            RT.DurationOfResearch = TimeFrame.TwoYears;
            RT.ListOfPublication  = new Paper[1] {
                new Paper {
                    Name              = "some paper",
                    Author            = new Person(fName: "Roman", sName: "Chubak", bDay: DateTime.Today),
                    DateOfPublication = DateTime.Today
                }
            };
            Console.WriteLine(RT);
            RT.AddPapers(
                new Paper
            {
                Name              = "paper",
                Author            = new Person(fName: "Oleh", sName: "Bodnar", bDay: DateTime.Today),
                DateOfPublication = DateTime.Today
            });
            Console.WriteLine(RT);
            Console.WriteLine(RT.LastPublication);

            Console.WriteLine("\n\n\n");
            Console.WriteLine("enter the number of rows and columns separated by spaces: ");
            string[] nm      = Console.ReadLine().Split(' ');
            int      nRows   = Convert.ToInt32(nm[0]);
            int      nColums = Convert.ToInt32(nm[1]);

            ResearchTeam[] arr = new ResearchTeam[nRows * nColums];
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = new ResearchTeam();
            }
            ResearchTeam[,] arr2 = new ResearchTeam[nRows, nColums];
            for (int i = 0; i < nRows; i++)
            {
                for (int j = 0; j < nColums; j++)
                {
                    arr2[i, j] = new ResearchTeam();
                }
            }
            ResearchTeam[][] arr3 = new ResearchTeam[WhatNumberOfRows(nRows * nColums)][];
            for (int i = 0; i < arr3.Length; i++)
            {
                arr3[i] = new ResearchTeam[i + 1];
                for (int j = 0; j < arr3[i].Length; j++)
                {
                    arr3[i][j] = new ResearchTeam();
                }
            }

            int start = Environment.TickCount;

            foreach (var element in arr)
            {
                element.NameOfOrganisation = "afsa";
            }
            int end = Environment.TickCount;

            Console.WriteLine("one-dimensional array : " + (end - start) + "msec");


            start = Environment.TickCount;
            foreach (var element in arr2)
            {
                element.NameOfOrganisation = "afsa";
            }
            end = Environment.TickCount;
            Console.WriteLine("two-dimensional array : " + (end - start) + "msec");


            start = Environment.TickCount;
            foreach (var firstDemention in arr3)
            {
                foreach (var secondDemention in firstDemention)
                {
                    secondDemention.NameOfOrganisation = "afsa";
                }
            }
            end = Environment.TickCount;
            Console.WriteLine("stepped array array : " + (end - start) + "msec");

            Console.ReadKey();
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            Person       KarinaVasilkova   = new Person("Karina", "Vasilkova", new DateTime(1996, 09, 10));
            Paper        firstPapar        = new Paper("Title1", KarinaVasilkova, (2018, 09, 31));
            ResearchTeam firstResearchTeam = new ResearchTeam();

            Console.WriteLine("First task is (toShortString):\n" + firstResearchTeam.ToShortString());
            //Console.WriteLine("Second task is (TimeFrame):\n" + TimeFrame.Year + " " + TimeFrame.TwoYears + " " + TimeFrame.Long);

            //firstResearchTeam = new ResearchTeam("My ResearchTeam", TimeFrame.Year, TimeFrame.TwoYears, 10, new[] { firstArtucle });
            Console.WriteLine("Third task is (toString + ResearchTeam all params):\n" + firstResearchTeam);

            firstResearchTeam.AddPaper(firstPapar, firstPapar);
            Console.WriteLine("Fourth task is (toString + AddPaper):\n" + firstResearchTeam.ToString());

            Console.WriteLine("Fifth task is (timer in massifs):\n");
            string inputText = Console.ReadLine();

            int nRows    = Int32.Parse(inputText.Split(' ')[0]);
            int mColumns = Int32.Parse(inputText.Split(' ')[1]);

            int sum  = 0;
            int size = 0;

            while (sum < nRows * mColumns)
            {
                sum += ++size;
            }

            Paper[] oneDimension = new Paper[nRows * mColumns];
            Paper[,] twoDimension = new Paper[nRows, mColumns];
            Paper[][] cogged = new Paper[size][];

            var timeStart = Environment.TickCount;

            for (int i = 0; i < nRows * mColumns; i++)
            {
                oneDimension[i] = firstPapar;
            }
            var timeEnd = Environment.TickCount;

            Console.WriteLine("\nOne dimension is: " + (timeEnd - timeStart));

            timeStart = Environment.TickCount;
            for (int i = 0; i < nRows; i++)
            {
                for (int j = 0; j < mColumns; j++)
                {
                    twoDimension[i, j] = firstPapar;
                }
            }
            timeEnd = Environment.TickCount;
            Console.WriteLine("\nTwo dimension is: " + (timeEnd - timeStart));

            for (int i = 0; i < size; i++)
            {
                if (i == size - 1)
                {
                    cogged[i] = new Paper[nRows * mColumns - (sum - size)];
                    break;
                }
                cogged[i] = new Paper[i + 1];
            }

            timeStart = Environment.TickCount;
            foreach (var lineArray in cogged)
            {
                for (var j = 0; j < lineArray.Length; j++)
                {
                    lineArray[j] = firstPapar;
                }
            }
            timeEnd = Environment.TickCount;
            Console.WriteLine("\nTwo dimension2 is: " + (timeEnd - timeStart));

            Console.Read();
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            int NumberOfElements = 0;

            Console.WriteLine("Please, enter the number of elements in one - dimensional array");
            NumberOfElements = Convert.ToInt32(Console.ReadLine());

            Paper[] ODArray = new Paper[NumberOfElements];
            for (int i = 0; i < NumberOfElements; i++)
            {
                ODArray[i] = new Paper();
            }


            Console.WriteLine("Please, enter rows and columns of two - dimensional array, using ',': ");
            string[] RowsAndColumnsTDArr      = Console.ReadLine().Split(',');
            int      NumberOfRowsInTDArray    = int.Parse(RowsAndColumnsTDArr[0]);
            int      NumberOfColumnsInTDArray = int.Parse(RowsAndColumnsTDArr[1]);

            Paper[,] TDArray = new Paper[NumberOfRowsInTDArray, NumberOfColumnsInTDArray];

            for (int i = 0; i < NumberOfRowsInTDArray; i++)
            {
                for (int j = 0; j < NumberOfColumnsInTDArray; j++)
                {
                    TDArray[i, j] = new Paper();
                }
            }


            Console.WriteLine("Please, enter rows and columns of ragged array, using ',': ");
            string[] RowsAndColumnsRaggedArr      = Console.ReadLine().Split(',');
            int      NumberOfColumnsInRaggedArray = int.Parse(RowsAndColumnsRaggedArr[0]);
            int      NumberOfRowsInRaggedArray    = int.Parse(RowsAndColumnsRaggedArr[1]);

            Paper[][] RaggedArray = new Paper[NumberOfRowsInRaggedArray][];
            for (int i = 0; i < NumberOfRowsInRaggedArray; i++)
            {
                RaggedArray[i] = new Paper[NumberOfColumnsInRaggedArray];
            }

            for (int i = 0; i < NumberOfRowsInRaggedArray; i++)
            {
                for (int j = 0; j < NumberOfColumnsInRaggedArray; j++)
                {
                    RaggedArray[i][j] = new Paper();
                }
            }

            int start = Environment.TickCount;

            for (int i = 0; i < NumberOfElements; i++)
            {
                ODArray[i].Name = "qwe";
            }
            int end = Environment.TickCount - start;

            Console.WriteLine("First result is: " + end);

            start = Environment.TickCount;
            for (int i = 0; i < NumberOfRowsInTDArray; i++)
            {
                for (int j = 0; j < NumberOfColumnsInTDArray; j++)
                {
                    TDArray[i, j].Name = "qwe";
                }
            }
            end = Environment.TickCount - start;
            Console.WriteLine("Second result is: " + end);

            start = Environment.TickCount;
            for (int i = 0; i < NumberOfRowsInRaggedArray; i++)
            {
                for (int j = 0; j < NumberOfColumnsInRaggedArray; j++)
                {
                    RaggedArray[i][j].Name = "qwe";
                }
            }
            end = Environment.TickCount - start;
            Console.WriteLine("Third result is: " + end);

            Console.WriteLine("\n-----------------------------------------------------\n");

            ResearchTeam DyatlovTeam = new ResearchTeam("Pereval", "Dyatlov Team", 6845312, TimeFrame.Year);

            Console.WriteLine(DyatlovTeam.ToShortString());

            Console.WriteLine();
            Console.WriteLine(DyatlovTeam[TimeFrame.Year]);
            Console.WriteLine(DyatlovTeam[TimeFrame.TwoYears]);

            DyatlovTeam.ResearchPublications = new Paper[] { new Paper() };
            Person Dyatlov = new Person("Igor", "Dyatlov", new DateTime(1936, 01, 13));
            Paper  p1      = new Paper("Taina", Dyatlov, new DateTime(1959, 02, 02));
            Paper  p2      = new Paper("Taina2", Dyatlov, new DateTime(1960, 02, 03));

            DyatlovTeam.AddPapers(p1, p2);
            Console.WriteLine(DyatlovTeam.ToShortString());



            Console.ReadKey();
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            ResearchTeam team = new ResearchTeam();

            Console.WriteLine(team.ToShortString());

            Console.WriteLine($"Индексатор для Year = : Year = {team[TimeFrame.Year]} TwoYears = {team[TimeFrame.TwoYears]} Long = {team[TimeFrame.Long]}\n");

            team.ResearchName     = "Поиск Немо";
            team.ResearchDuration = TimeFrame.TwoYears;
            team.LicenceNumber    = 18999;
            team.CompanyName      = "ООО \"Рыболов\"";
            team.ArticleArr       = new Paper[] { new Paper(), new Paper("Первая попытка", new Person(), new DateTime(2002, 8, 13)),
                                                  new Paper("Вторая попытка", new Person("Фёдр", "Макгрегор", new DateTime(2009, 2, 9)), new DateTime(2010, 10, 12)) };
            Console.WriteLine(team.ToString() + "\n");

            team.AddPapers(new Paper("Новое исследование", new Person("Иван", "Иванов", new DateTime(1998, 10, 7)), new DateTime(2021, 9, 10)));
            Console.WriteLine(team.ToString() + "\n");
            Console.WriteLine("Последнее исследование: \n" + team.LastArticle.ToString());

            //Сравнение скорости работы для одномерного, прямоугольного и ступенчатого массива

            string[] strArr = null;
            int      strNum = 0, colNum = 0;

            while (true)
            {
                Console.WriteLine("Введите ncol, nrow, через запятую");
                string line = Console.ReadLine();

                strArr = line.Split(',');
                try
                {
                    strNum = Int32.Parse(strArr[0]);
                    colNum = Int32.Parse(strArr[1]);
                    break;
                }
                catch (FormatException)
                {
                    Console.WriteLine("Вы допустили ошибку при вводе!");
                }
                catch (ArgumentNullException)
                {
                    Console.WriteLine("Вы допустили ошибку при вводе!");
                }
            }
            int resSize = strNum * colNum;

            Paper[] paperLinearArr = new Paper[resSize];
            for (int i = 0; i < resSize; i++)
            {
                paperLinearArr[i] = new Paper();
            }


            Random random = new Random();

            Paper[][] paperStairsArr = new Paper[strNum][];
            for (int i = 0; i < strNum - 1; i++)
            {
                int t_size = random.Next(1, colNum);
                paperStairsArr[i] = new Paper[t_size];
                resSize          -= t_size;
            }
            paperStairsArr[strNum - 1] = new Paper[resSize];

            for (int i = 0; i < paperStairsArr.Length; i++)
            {
                for (int j = 0; j < paperStairsArr[i].Length; j++)
                {
                    paperStairsArr[i][j] = new Paper();
                }
            }

            Paper[,] paperRectangleArr = new Paper[strNum, colNum];
            for (int i = 0; i < strNum; i++)
            {
                for (int j = 0; j < colNum; j++)
                {
                    paperRectangleArr[i, j] = new Paper();
                }
            }


            Stopwatch sw = new Stopwatch();

            sw.Start();
            foreach (Paper[] arr in paperStairsArr)
            {
                foreach (Paper item in arr)
                {
                    item.ArticleName = "NewName";
                }
            }
            sw.Stop();
            Console.WriteLine("Результат для зубчатого массива: " + sw.ElapsedMilliseconds.ToString());

            sw.Restart();
            foreach (Paper item in paperRectangleArr)
            {
                item.ArticleName = "NewName";
            }
            sw.Stop();
            Console.WriteLine("Результат для прямоугольного массива: " + sw.ElapsedMilliseconds.ToString());

            sw.Restart();
            foreach (Paper item in paperLinearArr)
            {
                item.ArticleName = "NewName";
            }
            sw.Stop();
            Console.WriteLine("Результат для линейного массива: " + sw.ElapsedMilliseconds.ToString());
        }