Beispiel #1
0
        static void Main(string[] args)
        {
            // 1st task
            var team1 = new Team();
            var team2 = new Team();

            Console.WriteLine("Hash code of 1st: {0} Hash of 2nd : {1} \n \n", team1.GetHashCode(), team2.GetHashCode());

            Console.WriteLine("TEAMS THE SAME?! " + team1.Equals(team2) + "\n \n");
            Console.WriteLine("References the same? : " + ReferenceEquals(team1, team2) + "\n\n");
            // 2nd task
            try
            {
                team1.RegistrationGetSet = -100;
            }
            catch (ArgumentException arg)
            {
                Console.WriteLine(arg.Message + "\n \n");
            }
            // 3rd task
            ResearchTeam resTeam = new ResearchTeam("ResearchName", "OrganizationName", 3, TimeFrame.TwoYears);

            resTeam.AddPapers(new Paper[] { new Paper() });
            resTeam.AddPersons(new Person[] { new Person() });

            Console.WriteLine(resTeam.ToString());
        }
Beispiel #2
0
        //метод void AddDefaults (), c помощью которого можно добавить некоторое число элементов ResearchTeam для инициализации коллекции по умолчанию;

        public void AddDefaults()
        {
            ResearchTeam tempRT = new ResearchTeam();
            // вызываю епаный метод для высчитывания ключа, на который указывает ДЕГЕНЕРАТ
            TKey key = myKeySelector(tempRT);

            researchteamDictionary.Add(key, tempRT);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            // 1st task
            var team1 = new Team();
            var team2 = new Team();

            Console.WriteLine("Hash code of 1st: {0} Hash of 2nd : {1} \n \n", team1.GetHashCode(), team2.GetHashCode());

            Console.WriteLine("TEAMS THE SAME?! " + team1.Equals(team2) + "\n \n");
            Console.WriteLine("References the same? : " + ReferenceEquals(team1, team2) + "\n\n");
            // 2nd task
            try
            {
                team1.RegistrationGetSet = -100;
            }
            catch (ArgumentException arg)
            {
                Console.WriteLine(arg.Message + "\n \n");
            }
            // 3rd task
            ResearchTeam resTeam = new ResearchTeam("ResearchName", "OrganizationName", 3, TimeFrame.TwoYears);

            resTeam.AddPapers(new Paper());
            resTeam.AddPersons(new Person());
            Console.WriteLine(resTeam.ToString());

            // 4th task
            Console.WriteLine(resTeam.GetTeam);
            // 5th task
            ResearchTeam resTeam2 = resTeam.DeepCopy() as ResearchTeam;

            resTeam.ResearchName = "Math";
            resTeam2.AddPersons(new Person("Ser", "Gay", new DateTime(2000, 6, 1)));
            Console.WriteLine(resTeam.ToString());
            Console.WriteLine();
            Console.WriteLine(resTeam2.ToString());
            Console.WriteLine();


            // 6 task
            Console.WriteLine("\n   Persons without publications:");
            resTeam.AddPersons(new Person("Sereja", "Oleja", new DateTime(2015, 03, 10)));

            foreach (Person person in resTeam.PersonsWithoutPublications())
            {
                Console.WriteLine("\n" + person);
            }


            // 7 task
            resTeam.AddPapers(new Paper("NewPub", new Person(), new DateTime(2016, 01, 01)));
            foreach (Paper person in resTeam.GetPubliscationsByYear(2))
            {
                Console.WriteLine("\n" + person);
            }
        }
Beispiel #4
0
        public string Time(int n)
        {
            ResearchTeam rt = new ResearchTeam()
            {
                RegistrationGetSet = n
            };
            string info = "";
            bool   temp;

            System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch();
            time.Start();
            Team temp1 = rt as Team;

            temp = TestTeamList.Contains(temp1);
            time.Stop();
            info += String.Format("Время поиска элемента в List<Team> - {0}\n", time.Elapsed);

            time.Reset();
            time.Start();
            string temp2 = rt.ToString();

            temp = TestStringList.Contains(temp2);
            time.Stop();
            info += String.Format("Время поиска элемента в List<string> - {0}\n", time.Elapsed);

            time.Reset();
            time.Start();
            temp = TestTeamDictionary.ContainsKey(temp1);
            time.Stop();
            info += String.Format("Время поиска по ключу в Dictionary<Team,ResearchTeam> - {0}\n", time.Elapsed);

            time.Reset();
            time.Start();
            temp = TestTeamDictionary.ContainsValue(rt);
            time.Stop();
            info += String.Format("Время поиска по значению в Dictionary<Team,ResearchTeam> - {0}\n", time.Elapsed);

            time.Reset();
            time.Start();
            temp = TestStringDictionary.ContainsKey(temp2);
            time.Stop();
            info += String.Format("Время поиска по ключу в Dictionary<string,ResearchTeam> - {0}\n", time.Elapsed);

            time.Reset();
            time.Start();
            temp = TestStringDictionary.ContainsValue(rt);
            time.Stop();
            info += String.Format("Время поиска по значению в Dictionary<string,ResearchTeam> - {0}\n", time.Elapsed);

            return(info);
        }
Beispiel #5
0
        public override object DeepCopy()
        {
            object copy = new ResearchTeam(this.researchName, this.organizationName, base.registrationNumber, this.researchTime);

            foreach (Paper p in this.listOfPublications)
            {
                ((ResearchTeam)copy).AddPapers((Paper)(p.DeepCopy()));
            }
            foreach (Person p in this.listOfPersons)
            {
                ((ResearchTeam)copy).AddPersons((Person)(p.DeepCopy()));
            }
            return(copy);
        }
Beispiel #6
0
        public TestCollectilons(int count)
        {
            teams   = new List <Team>();
            strings = new List <string>();
            TeamsAndResearchesDict = new Dictionary <Team, ResearchTeam>();
            StringsAndResearchDict = new Dictionary <string, ResearchTeam>();

            for (int i = 0; i < count; i++)
            {
                ResearchTeam research1 = GenerateReserchTeamObject(i);
                Team         team1     = new Team("OrgName" + i, 1 + i);
                string       str       = "String " + i;
                teams.Add(team1);
                strings.Add(str);
                TeamsAndResearchesDict.Add(team1, research1);
                StringsAndResearchDict.Add(str, research1);
            }
        }