public static void EvaluateCompatibility(Dancer dancer, Dancer candidate)
        {
            List<DancingSkill> dancerDancingSkills = GetDancingSkills(dancer);
            List<DancingSkill> candidateDancingSkills = GetDancingSkills(candidate);

            double compatibilityPoints = 0.0;
            double maksCompatibilityPoints = 0.0;

            foreach (DancingSkill dancingSkill in dancerDancingSkills)
            {
                if (candidateDancingSkills.Contains<DancingSkill>(dancingSkill))
                    compatibilityPoints += skillCompatibilityRate;
                maksCompatibilityPoints += skillCompatibilityRate;
            }

            foreach (StyleDances styleDance in dancer.StyleDancesKnownEnum)
            {
                if (candidate.StyleDancesKnownEnum.Contains<StyleDances>(styleDance))
                    compatibilityPoints += danceCompatibilityRate;
                maksCompatibilityPoints += danceCompatibilityRate;
            }

            maksCompatibilityPoints += Math.Abs(dancer.Height - candidate.Height);
            maksCompatibilityPoints += Math.Abs(dancer.Age - candidate.Age);

            candidate.CompatibilityRate = compatibilityPoints / maksCompatibilityPoints;
        }
Exemplo n.º 2
0
        public static List<Dancer> FindMatchingPartners(Dancer dancer)
        {
            List<Dancer> matchingPartners = new List<Dancer>();

            matchingPartners = GetPossibleMatches(dancer, matchingPartners);

            foreach (Dancer candidate in matchingPartners)
                dancer.EvaluateCompatibility(candidate);

            return matchingPartners.OrderByDescending(d => d.CompatibilityRate).ToList(); ;
        }
        private static List<DancingSkill> GetDancingSkills(Dancer dancer)
        {
            List<DancingSkill> skills = new List<DancingSkill>();

            foreach (StyleDance styleDance in dancer.StyleDancesKnown)
            {
                foreach (DancingSkill dancingSkill in styleDance.DancigSkillsRequired)
                {
                    if (!skills.Contains<DancingSkill>(dancingSkill))
                        skills.Add(dancingSkill);
                }
            }

            return skills;
        }
Exemplo n.º 4
0
        private static List<Dancer> GetPossibleMatches(Dancer dancer, List<Dancer> matchingPartners)
        {
            matchingPartners = Model.Dancers.Where<Dancer>(d => d.Gender != dancer.Gender).ToList<Dancer>();

            bool pairDances = false;
            bool groupDances = false;

            if (dancer.StyleDancesKnown.Find(d => d.DanceKind == DanceKinds.Pair) != null)
                pairDances = true;
            if (dancer.StyleDancesKnown.Find(d => d.DanceKind == DanceKinds.Group) != null)
                groupDances = true;

            if (groupDances && pairDances)
                return matchingPartners;
            if (pairDances)
                return matchingPartners.Where<Dancer>(dr => dr.StyleDancesKnown.Find(d => d.DanceKind == DanceKinds.Pair) != null).ToList<Dancer>();
            if (groupDances)
                return matchingPartners.Where<Dancer>(dr => dr.StyleDancesKnown.Find(d => d.DanceKind == DanceKinds.Group) != null).ToList<Dancer>();

            return matchingPartners;
        }
        private static void InitializeDancers()
        {
            int dancerId = 1;
            Model.Dancers = new List<Dancer>();

            #region Male Dancers

            Dancer newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Marcin", Surname = "Głowa", Age = 23, Height = 184, Gender = Genders.MaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.EnglishWaltz);
            newDancer.AddKnownDance(StyleDances.Tango);
            newDancer.AddKnownDance(StyleDances.VienneseWaltz);
            newDancer.AddKnownDance(StyleDances.Pasodoble);
            newDancer.AddKnownDance(StyleDances.Samba);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Przemek", Surname = "Curzytek", Age = 20, Height = 181, Gender = Genders.MaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            //newDancer.AddKnownDance(StyleDances.EnglishWaltz);
            //newDancer.AddKnownDance(StyleDances.Tango);
            //newDancer.AddKnownDance(StyleDances.VienneseWaltz);
            //newDancer.AddKnownDance(StyleDances.SlowFoxtrott);
            //newDancer.AddKnownDance(StyleDances.Tango);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Michał", Surname = "Tutka", Age = 22, Height = 175, Gender = Genders.MaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            //newDancer.AddKnownDance(StyleDances.Samba);
            //newDancer.AddKnownDance(StyleDances.ChaChaCha);
            //newDancer.AddKnownDance(StyleDances.Rumba);
            //newDancer.AddKnownDance(StyleDances.Pasodoble);
            //newDancer.AddKnownDance(StyleDances.Jive);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Wojtek", Surname = "Korzeniowski", Age = 15, Height = 161, Gender = Genders.MaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            //newDancer.AddKnownDance(StyleDances.EnglishWaltz);
            //newDancer.AddKnownDance(StyleDances.Tango);
            //newDancer.AddKnownDance(StyleDances.VienneseWaltz);
            //newDancer.AddKnownDance(StyleDances.SlowFoxtrott);
            //newDancer.AddKnownDance(StyleDances.Tango);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Przemek", Surname = "Curzytek", Age = 20, Height = 181, Gender = Genders.MaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            //newDancer.AddKnownDance(StyleDances.EnglishWaltz);
            //newDancer.AddKnownDance(StyleDances.Tango);
            //newDancer.AddKnownDance(StyleDances.VienneseWaltz);
            //newDancer.AddKnownDance(StyleDances.SlowFoxtrott);
            //newDancer.AddKnownDance(StyleDances.Tango);
            Model.Dancers.Add(newDancer);

            #endregion

            #region Female Dancers

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Małgorzata", Surname = "Curzytek", Age = 20, Height = 171, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.EnglishWaltz);
            newDancer.AddKnownDance(StyleDances.Tango);
            newDancer.AddKnownDance(StyleDances.VienneseWaltz);
            newDancer.AddKnownDance(StyleDances.SlowFoxtrott);
            newDancer.AddKnownDance(StyleDances.Tango);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Basia", Surname = "Górska", Age = 22, Height = 172, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Samba);
            newDancer.AddKnownDance(StyleDances.ChaChaCha);
            newDancer.AddKnownDance(StyleDances.Rumba);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Zuzia", Surname = "Kuza", Age = 19, Height = 169, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Samba);
            newDancer.AddKnownDance(StyleDances.Rumba);
            newDancer.AddKnownDance(StyleDances.Ballet);
            newDancer.AddKnownDance(StyleDances.Tango);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Ania", Surname = "Haberka", Age = 23, Height = 163, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Samba);
            newDancer.AddKnownDance(StyleDances.ChaChaCha);
            newDancer.AddKnownDance(StyleDances.Pasodoble);
            newDancer.AddKnownDance(StyleDances.Jive);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Kasia", Surname = "Lament", Age = 23, Height = 176, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.ChaChaCha);
            newDancer.AddKnownDance(StyleDances.Rumba);
            newDancer.AddKnownDance(StyleDances.Pasodoble);
            newDancer.AddKnownDance(StyleDances.Jive);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Ania", Surname = "Uznańska", Age = 21, Height = 179, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.CasinoSalsa);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Ania", Surname = "Wojna", Age = 28, Height = 179, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.RockAndRoll);
            newDancer.AddKnownDance(StyleDances.Jive);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Marta", Surname = "Migdał", Age = 23, Height = 165, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Krakowiak);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Asia", Surname = "Kosaty", Age = 23, Height = 165, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Kujawiak);
            newDancer.AddKnownDance(StyleDances.Bollywood);
            newDancer.AddKnownDance(StyleDances.Ballet);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Hanna", Surname = "Kurowska", Age = 13, Height = 146, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Zumba);
            newDancer.AddKnownDance(StyleDances.StepStep);
            newDancer.AddKnownDance(StyleDances.Belly);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Weronika", Surname = "Wcisło", Age = 14, Height = 147, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Ballet);
            newDancer.AddKnownDance(StyleDances.Locking);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Magdalena", Surname = "Starowicz", Age = 14, Height = 155, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Samba);
            newDancer.AddKnownDance(StyleDances.RockAndRoll);
            newDancer.AddKnownDance(StyleDances.Jive);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Joanna", Surname = "Ziemniak", Age = 26, Height = 180, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Belly);
            newDancer.AddKnownDance(StyleDances.Bollywood);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Natalia", Surname = "Kursa", Age = 25, Height = 172, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Samba);
            newDancer.AddKnownDance(StyleDances.ChaChaCha);
            newDancer.AddKnownDance(StyleDances.Rumba);
            newDancer.AddKnownDance(StyleDances.Jive);
            newDancer.AddKnownDance(StyleDances.EnglishWaltz);
            newDancer.AddKnownDance(StyleDances.Tango);
            newDancer.AddKnownDance(StyleDances.Belly);
            Model.Dancers.Add(newDancer);

            newDancer = new Dancer() { ID = dancerId, DancerID = dancerId++, Name = "Ilona", Surname = "Kryszak", Age = 20, Height = 171, Gender = Genders.FemaleGender, Attitudes = new List<Attitude>(), StyleDancesKnown = new List<StyleDance>(), StyleDancesKnownEnum = new List<StyleDances>() };
            newDancer.AddKnownDance(StyleDances.Samba);
            newDancer.AddKnownDance(StyleDances.ChaChaCha);
            newDancer.AddKnownDance(StyleDances.Rumba);
            newDancer.AddKnownDance(StyleDances.SlowFoxtrott);
            newDancer.AddKnownDance(StyleDances.QuickStep);
            Model.Dancers.Add(newDancer);
            #endregion
        }
Exemplo n.º 6
0
 public void EvaluateCompatibility(Dancer candidate)
 {
     CompatibilityManager.EvaluateCompatibility(this, candidate);
 }